[Twisted-Python] A problem with very long blocking thread in Twisted

Heungsub Lee h at subl.ee
Wed Aug 10 09:49:07 EDT 2011

Hi, fellow programmers.

I have a problem with very long blocking thread(may not be finished) in

from socket import *
> from twisted.internet import reactor
> def consuming():
>     while reactor.running:
>         amqp_consumer.wait() # waiting for very long time or forever
> reactor.callInThread(consuming)

The process follows the below timeline:

>--: Started
---: Process
--X: Terminated
 ^ : Keyboard Input


main loop |>--------------------X
   thread | >--------------------------------------------... long time later


main loop |>--------------------X
   thread | >-------------------X

To solve this problem, I'd like to set threads as daemon. So that all
related threads are terminated when main loop is interrupted. Any idea on
this problem will be appreciated.

Heungsub Lee
Mobile: +82-10-3215-2380
Site: http://subl.ee/
GitHub: http://github.com/sublee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20110810/f3731d29/attachment.htm 

More information about the Twisted-Python mailing list