[Twisted-Python] thread pool question

L. Daniel Burr ldanielburr at mac.com
Thu Mar 22 16:47:33 MDT 2007


On Thu, 22 Mar 2007 17:03:29 -0500, Rutt, Benjamin <Benjamin.Rutt at gs.com>  
wrote:

> Still isn't working for me:
>
> #!/usr/bin/env python
> from twisted.internet import reactor
> from twisted.internet import threads
> def aSillyBlockingMethod(x):
>     import time
>     time.sleep(2)
>     print x
> d = threads.deferToThread(aSillyBlockingMethod, "2 seconds have passed")
> d.addBoth(lambda _: reactor.stop())
>
> Does this work for you?
>

You have to run the reactor, or nothing will ever start.

Try adding reactor.run()

Hope this helps,

L. Daniel Burr




More information about the Twisted-Python mailing list