[Twisted-Python] sleeping in inlineCallbacks
ellisonbg.net at gmail.com
Thu Oct 29 10:59:58 EDT 2009
In general, please reply on this list inline, with quoting and trimming,
> like so:
> This might seem like a minor thing, but it really helps those of us who
> have to follow long discussions and many mailing lists.
Sorry, just being lazy...
I have been using Twisted for years but only recently began to use
> inlineCallbacks (couldn't give up Python 2.4 support until recently). This
> simple asynch. sleep function is fantastic. Just today I used to it with
> inlineCallbacks to dramatically clean up some complex deferred logic.
> Which asynch sleep function?
This one posted by Paul:
d = defer.Deferred()
reactor.callLater(seconds, d.callback, seconds)
I hope you're not talking about this stuff, quoted in your message:
> On Wed, Oct 7, 2009 at 8:28 PM, Andrew Bennetts <andrew at bemusement.org>wrote:
>> > What about Deferred.setTimeout?
> Please note spiv's reply:
> Deferred.setTimeout is a poor API and is deprecated (despite what the
>> automatically generated API docs think).
> and his recommendation:
> So please, don't use setTimeout, and definitely do not recommend it to
Definitely not - I did see this warning.
> I hope that, instead, you're talking about the deferLater function that was
> introduced in Twisted 8.0?
> This will act like an async 'sleep' if its result is yielded from an
> @inlineCallbacks function.
I looked at deferLater, but am not using it right now. The sleep function I
am using is basically the same as this - in my case "sleep" turned out to be
a little simpler because I don't have to create and pass the clock around.
But I will probably use deferLater for this same purpose in the future as
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python