Python subprocess question

Duncan Booth duncan.booth at invalid.invalid
Tue Jan 6 07:46:13 EST 2009


"Alexi Zuo" <alexi.zuo at gmail.com> wrote:

> Hi everyone,
> 
> Here I have a simple program which starts a thread and the thread use
> Popen to execute a shell cmd which needs a long time.  I want to stop
> the thread once I type "ctrl+C" (KeyboardInterrupt). But in fact this
> program enters a dead loop. Can anyone tell me what is wrong?

The KeyboardInterrupt exception is being raised in your main thread which 
doesn't handle it so it just terminates. Your child thread isn't marked as 
a daemon thread so the program won't exit until the child thread has also 
terminated.




More information about the Python-list mailing list