[Twisted-Python] sleeping in inlineCallbacks

Andrew Bennetts andrew at bemusement.org
Wed Oct 7 21:28:22 MDT 2009


Mikhail Terekhov wrote:
>    On Wed, Oct 7, 2009 at 6:04 PM, Phil Christensen <[1]phil at bubblehouse.org>
>    wrote:
> 
>      Paul's example will work just fine. Also, AFAIK there's no existing
>      twisted function to do replicate an asynchronous sleep() in this way.
> 
>      -phil
> 
>    What about Deferred.setTimeout?
>    [2]http://twistedmatrix.com/documents/current/api/twisted.internet.defer.Deferred.html#setTimeout
>    IMHO it solves similar problem.

Deferred.setTimeout is a poor API and is deprecated (despite what the
automatically generated API docs think).
<http://twistedmatrix.com/trac/ticket/178> has some discussion (and links to
more discussion) explaining what's wrong with it, and what a good replacement
would look like.

So please, don't use setTimeout, and definitely do not recommend it to others!

-Andrew.





More information about the Twisted-Python mailing list