[PEAK] Anybody using reactors?

alexander smishlajev alex at ank-sia.com
Wed Jan 14 13:17:31 EST 2004


Phillip J. Eby wrote, at 14.01.2004 19:19:

>>> I'm curious how this use case would be handled with 'peak.events'.  I 
>>> haven't yet felt a strong need for it myself, obviously, else I'd 
>>> have added it to UntwistedReactor.  Do you have a sample usage or 
>>> kinds of usage that I could see, so I could see how I'd write it with 
>>> peak.events, and make sure it's still tractable?
>>
>> we use it to handle timeouts: timeout procedure is registered with 
>> callLater(), and we continue with normal data flow.  when expected 
>> event arrives, timeout procedure (if any) is removed from the queue, 
>> with possible resheduling at a later time.
> 
> Ah.  Okay, so something like:
> 
> while True:
> 
>     yield events.AnyOf(data.readable, scheduler.timeout(30)); 
> src,evt=events.resume()
> 
>     if src is data.readable:
>         # got something, act on it
>     else:
>         # timed out
> 
> would work, then?

it seems so, at least at the first glance.  (i do not fully feel the 
event yelding mechanics yet, but i've already got an impression that it 
must be much more cosy than our current state machines.)

best wishes,
alex.






More information about the PEAK mailing list