Killing/Terminating a running thread
Heiko Wundram
heikowu at ceosg.de
Sat Sep 7 17:25:10 EDT 2002
Am Sam, 2002-09-07 um 22.42 schrieb Chris Liechti:
> sound like the news thread "Interrupting Python" could be interresting for
> you...
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():
> do_stuff()
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... :)
Yours,
Heiko Wundram
Netzwart Wohnheim-D
Zimmer 2206 - Universität 18 - 66123 Saarbrücken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://mail.python.org/pipermail/python-list/attachments/20020907/b2535ae5/attachment.sig>
More information about the Python-list
mailing list