Re: [Twisted-Python] sleeping in inlineCallbacks
"Brian" == Brian Granger
writes: Brian> I looked at deferLater, but am not using it right now. The sleep Brian> function I am using is basically the same as this - in my case Brian> "sleep" turned out to be a little simpler because I don't have to Brian> create and pass the clock around. But I will probably use Brian> deferLater for this same purpose in the future as well.
Hi Brian Forgive me for butting in, but.... why :-) Importing the reactor is no big deal, and if you use task.deferLater, apart from not having to write any code you also have the advantage of being able to pass it a result that the deferred will be called with. For this reason you can also put a task.deferLater result into a callback chain to achieve an async sleep and it will duly pass the result along. E.g.: from twisted.internet import reactor, task, defer d = somethingReturningADeferred() d.addCallback(lambda x: task.deferLater(reactor, 5.0, defer.passthru, x)) Terry
participants (4)
-
Brian Granger
-
exarkun@twistedmatrix.com
-
Terry Jones
-
Tristan Seligmann