[Twisted-Python] deferToThread help

Minesh Patel minesh at gmail.com
Wed Apr 29 14:45:09 EDT 2009


Sorry if this is a newbie question.

I have a blocking function that I defer to thread, let's say 'foo' and
I would like to add a callback that gets called after say 10 minues
after Thread finishes

def foo():
   # Blocks for a while

def bar():
   # Do some stuff

d = threads.deferToThread(foo)
d.addCallback(bar) # How can I add timing to the callback???

Currently I have the following code which works but doesn't account
for the threads execution time:

reactor.callInThread(self.bootIso, self.iloIp, pathToIsoRename)
# 10 minutes sleep
d = task.deferLater(reactor, 600, bar)

-- 
Thanks,
./Minesh




More information about the Twisted-Python mailing list