Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread exarkun
On 01:26 am, mithra...@mithrandi.net wrote: >On Thu, Oct 29, 2009 at 8:38 PM, Brian Granger > wrote: >>One question though - can someone explain the need/usage cases for >>task.Clock and the other things in task? > >Clock is a "fake" IReactorTime implementation; as the docstring says, >it is inten

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread Tristan Seligmann
On Thu, Oct 29, 2009 at 8:38 PM, Brian Granger wrote: > One question though - can someone explain the need/usage cases for > task.Clock and the other things in task? Clock is a "fake" IReactorTime implementation; as the docstring says, it is intended for writing unit tests where you want control

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread Brian Granger
> Hi Brian > > Forgive me for butting in, but why :-) > > Helpful butting in is more than fine.. > 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

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread Terry Jones
> "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. B

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread Brian Granger
Glyph, In general, please reply on this list inline, with quoting and trimming, > like so: > > http://en.wikipedia.org/wiki/Posting_style#Inline_replying > > This might seem like a minor thing, but it really helps those of us who > have to follow long discussions and many mailing lists. > So

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-29 Thread Glyph Lefkowitz
Hi Brian, In general, please reply on this list inline, with quoting and trimming, like so: http://en.wikipedia.org/wiki/Posting_style#Inline_replying This might seem like a minor thing, but it really helps those of us who have to follow long discussions and many mailing lists. Now,

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-28 Thread Brian Granger
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. Thanks, Bri

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Andrew Bennetts
Mikhail Terekhov wrote: >On Wed, Oct 7, 2009 at 6:04 PM, Phil Christensen <[1]p...@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

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Glyph Lefkowitz
On Wed, Oct 7, 2009 at 11:08 PM, Mikhail Terekhov wrote: > > What about Deferred.setTimeout? > http://twistedmatrix.com/documents/current/api/twisted.internet.defer.Deferred.html#setTimeout > IMHO it solves similar problem. > Deferred.setTimeout does something else. More importantly, it is depr

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Mikhail Terekhov
On Wed, Oct 7, 2009 at 6:04 PM, Phil Christensen 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? http://twistedmatrix.com/documents/current/api/twiste

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread exarkun
On 7 Oct, 10:40 pm, kevin.h...@gmail.com wrote: >On Wed, Oct 7, 2009 at 5:29 PM, wrote: >>Recent versions of Twisted include twisted.internet.defer.deferLater, >>a >>function rather similar to the sleep function defined above. >> >>Jean-Paul >Do you mean twisted.internet.task.deferLater? >Or am I

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Kevin Horn
On Wed, Oct 7, 2009 at 5:29 PM, wrote: > Recent versions of Twisted include twisted.internet.defer.deferLater, a > function rather similar to the sleep function defined above. > > Jean-Paul > > Do you mean twisted.internet.task.deferLater? Or am I missing something? Kevin Horn __

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread exarkun
On 10:04 pm, p...@bubblehouse.org wrote: >On Oct 7, 2009, at 3:46 PM, Matt Perry wrote: >>On 7 Oct 2009, at 20:30, Paul Thomas wrote: > >>>Is there any way to do something like "yield sleep(10)" inside an >>>@inlineCallbacks method? >>> >>>I realise I can do this: >>> >>>def sleep(seconds): >>>

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Phil Christensen
On Oct 7, 2009, at 3:46 PM, Matt Perry wrote: > On 7 Oct 2009, at 20:30, Paul Thomas wrote: >> Is there any way to do something like "yield sleep(10)" inside an >> @inlineCallbacks method? >> >> I realise I can do this: >> >> def sleep(seconds): >> d = defer.Deferred() >> reactor.callLater

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Matt Perry
reactor.callLater() is the best way to delay a certain function call. sleep() will block the entire program from running, which you probably don't want to do. On Wed, Oct 7, 2009 at 3:35 PM, Paul Thomas wrote: > > On 7 Oct 2009, at 20:30, Paul Thomas wrote: > > > Is there any way to do something

Re: [Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Paul Thomas
On 7 Oct 2009, at 20:30, Paul Thomas wrote: > Is there any way to do something like "yield sleep(10)" inside an > @inlineCallbacks method? I realise I can do this: def sleep(seconds): d = defer.Deferred() reactor.callLater(seconds, d.callback, seconds) return d but I wondered

[Twisted-Python] sleeping in inlineCallbacks

2009-10-07 Thread Paul Thomas
Is there any way to do something like "yield sleep(10)" inside an @inlineCallbacks method? ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python