[Twisted-Python] deferToThread()

Lenny G Arbage alengarbage at yahoo.com
Sat Mar 12 11:18:28 EST 2005

Can someone explain why the following example (lifted
straight out of
doesn't work?

from twisted.internet import threads

def doLongCalculation():
  return 3

def printResult(x):
  print "deferred returned "+str(x)

d = threads.deferToThread(doLongCalculation)
print "just waiting for deferred..."

Running the above, with or without time.sleep(),
results in a hanging process.  When run "just waiting
for deferred..." prints but the callback is never
invoked and the process hangs.

I'm using twisted 1.3, python 2.3.4 under Linux (FC3).

  Lenny G

Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!

More information about the Twisted-Python mailing list