[Twisted-Python] deferToThread()

Lenny G Arbage alengarbage at yahoo.com
Sat Mar 12 09:18:28 MST 2005


Can someone explain why the following example (lifted
straight out of
http://twistedmatrix.com/documents/current/howto/threading)
doesn't work?

from twisted.internet import threads

def doLongCalculation():
  #time.sleep(3)
  return 3

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

d = threads.deferToThread(doLongCalculation)
d.addCallback(printResult)
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!
http://smallbusiness.yahoo.com/resources/ 




More information about the Twisted-Python mailing list