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).
__________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/