Killing/Terminating a running thread
heikowu at ceosg.de
Sat Sep 7 23:25:10 CEST 2002
Am Sam, 2002-09-07 um 22.42 schrieb Chris Liechti:
> sound like the news thread "Interrupting Python" could be interresting for
I've looked at that, but the main problem is that this thread deals with
interrupting fullblown processes on the fly (from within the code), not
with interrupting a process by an exterior signal.
> the clean solution is to test for a flag and terminate if the flag is set.
> e.g. you could provide a function:
> def interrupted():
> return global_flag_if_user_wants_to_abort
> and in you function in the queue:
> def worker():
> while not interrupted():
This is what I do to shutdown the worker cleanly. The problem is:
do_stuff() doesn't return until it's complete, and I have no control
whatsoever about the internal workings of do_stuff().
What I actually wish to do is while the worker still is in do_stuff(),
to kill the worker as a whole, to discard all its data, when a timeout
on returning a value from do_stuff() occurs. It's not about clean
termination of a thread, but about killing the thread in case it takes
too long (in case do_stuff() takes to long).
Thanks for the advice anyway! :) I guess I at least did the general
interrupt on the worker right then... :)
Zimmer 2206 - Universität 18 - 66123 Saarbrücken
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 196 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
More information about the Python-list