[Twisted-Python] Twistd thread problem

Jp Calderone exarkun at divmod.com
Mon May 16 20:44:11 EDT 2005


On Mon, 16 May 2005 16:50:08 -0700, Jan Van Uytven <wyvern at crm3.com> wrote:
>Hi all,
>
>I coded an SMTP proxy that receives incoming e-mail requests and pushes the 
>received e-mail onto a Queue were it is processed by a worker thread that 
>finishes by sending the e-mail on to another SMTP server.
>
>The server part of the proxy was written in Twisted, but the worker thread 
>uses smtplib to fire off the processed e-mails (I didn't know how to use the 
>twisted smtp client in a thread).
>
>When I run the application using twistd -noy <appname>, it works great. When 
>I try to daemonize it (twistd -oy <appname>) the server part works, but the 
>worker thread doesn't. It creates and then I suspect it immediately dies, as 
>no error is returned upon creation. A debug of the queue reveals that the 
>thread is not pulling items off it. A debugging statement placed at the top 
>of the thread never runs, and the twistd log reports nothing wrong. I'm 
>using reactor.callInThread to start the worker function.
>
> [snip]
>
>Why would the worker thread act differently with twistd daemonized? Any 
>suggestions, advice, or hints would be welcome.
>
>Thanks,
>
>Jan
>

    Try changing the code so that it does not try to start any worker threads until after the reactor starts running (eg, using a Service or with reactor.callWhenRunning).

  Jp




More information about the Twisted-Python mailing list