2

I am attempting to run a python script from a QT application. This script need to to be run inside a virtualenv called venv. I can start the script but when I attempt .kill() the script will keep running until the console window is closed. Alternatively calling .terminate() just leaves the application hanging as it never properly finishes. Minimum replication below

QProcess python;
python.start( ".\\AdminConsole\\venv\\Scripts\\python "
              ".\\AdminConsole\\manage.py runserver 0.0.0.0:8000" );
python.waitForStarted();

python.kill();
python.waitForFinished();
printf( "Ended \n" );

return 0;

any help is appreciated

Edit

Reduce code in minimum replication

Community
  • 1
  • 1
quesyKing
  • 148
  • 7
  • Is the program executing correctly? Maybe you could give the program a command via stdin and it closes itself. – Rick Pat Mar 08 '19 at 00:28
  • The Program executes fine. I need to be able to kill it with out communication incase the program becomes unresponsive – quesyKing Mar 08 '19 at 13:56
  • Maybe this command is spawning multiple processes and you are killing only one of them. – Rick Pat Mar 08 '19 at 14:17
  • That seems likely, but then it makes no sense that they should die when the console closes instead when the parent dies – quesyKing Mar 08 '19 at 14:28
  • The console can be the parent of a process. What is the output of `QProcess::program()` while its running? – Rick Pat Mar 08 '19 at 14:33
  • `.\AdminConsole\venv\Scripts\activate.bat` So it seems that QProcess is running the second half separate ..... – quesyKing Mar 08 '19 at 14:40
  • Seems like it. Can you run the processes one after the other? – Rick Pat Mar 08 '19 at 14:51
  • They need to be run together. The first sets up the environment for the second – quesyKing Mar 08 '19 at 14:56
  • Yeah, not sure how to do that. Maybe ask a new question with this new info. – Rick Pat Mar 08 '19 at 15:02
  • I see that you are trying to launch an application of django, I have changed that application for a trivial example and it works so I am thinking that django is creating another process, ie with the kill of QProcess the manage.py was killed but the server is running in another side so with Qprocess it is not possible to kill it. In conclusion is a particular case related to how to launch django applications so a good starting point is to check how django launches the apps. – eyllanesc Mar 08 '19 at 20:07

0 Answers0