threading question
Siggy Brentrup
bsb at winnegan.de
Thu Apr 13 16:10:04 EDT 2000
"Thomas Heller" <thomas.heller at ion-tof.com> writes:
> I want a thread to run in parallel with the interactive
> interpreter.
> Simple:
>
> def do_work():
> import time
> while 1:
> time.sleep (1)
> ...
>
> import threading
change this
> threading.Thread (target=do_work()).start()
to
worker = threading.Thread (target=do_work)
worker.setDaemon(1)
worker.start()
> But when I hit EOF, python waits until this thread is finished.
> How can I avoid this? I want python to terminate the thread
> and exit in this case.
The main thread is special in installing an exitfunc that waits for
all non-daemonic threads to complete.
Siggy
More information about the Python-list
mailing list