Daemonic threads

moonseeker at my-deja.com moonseeker at my-deja.com
Tue Nov 16 09:46:34 CET 1999


In article <3830C73F.C8A7CA62 at DONT.LIKE.SPAM>,
  "David S." <I at DONT.LIKE.SPAM> wrote:
>
> I'm writing a CGI script that will launch a long-running process in the
> background, and return some HTML page to the browser.  Now, I know how
> to do that with 'fork()', but it seems to me that I should be able to do
> the same thing with a daemonic thread from the 'threading' module.
>
> I can't get that to work, though,
>
>    ...
>    xt = threading.Thread(target=_threadExec, args=(save, mail, None))
>    xt.setDaemon(1)
>    xt.start()
>    ...
>
> and the script exits with no thread running.  Non-daemonic threads seem
> to work as I expect them to.  What don't I understand about daemonic
> threads?  (Python 1.5.2 on Linux 2.2.7, if its relevant.)

Hi!

Daemonic threads die if no other non-daemonic thread lives. At the moment
your script (the main thread, non-daemonic) dies, all (daemonic) child
threads die too.

Mike


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list