[Python-ideas] PEP 3156 EventLoop: hide details of iterations and idleness?
Guido van Rossum
guido at python.org
Tue Jan 22 20:19:04 CET 2013
More information about the Python-ideas mailing list
Tue Jan 22 20:19:04 CET 2013
- Previous message: [Python-ideas] PEP 3156 EventLoop: hide details of iterations and idleness?
- Next message: [Python-ideas] PEP 3156 EventLoop: hide details of iterations and idleness?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jan 22, 2013 at 8:16 AM, Geert Jansen <geertj at gmail.com> wrote: > On Tue, Jan 22, 2013 at 4:31 PM, Ben Darnell <ben at bendarnell.com> wrote: > >> I don't understand what you mean by "events will always originate from IO" >> (I don't know anything about libdbus). > > What I meant is that if there is something to dispatch, then this is > due to an inbound IO (or a timeout for that matter). Due either event, > the loop will advance by one tick, and hit my call_every_iteration() > handler where I dispatch. > >> If the events are coming from IO >> that causes an event loop iteration, it must be from some tulip callback. >> Why can't that callback be responsible for scheduling any further >> dispatching that may be needed? > > Well your original question was why not call_repeatedly() instead of > call_every_iteration(). I tried to answer that for my use case. > > Indeed, call_soon() could be used to schedule a dispatch every time > when an IO is received. However, I preferred to have a fixed callback > that I do not need to allocate and register every time, for > efficiency. > >>> If Tornado doesn't have infrastructure for call_every_iteration() you >>> could emulate it with a function that re-reschedules itself using >>> call_soon() just before calling the callback. (See my first point >>> about when call_soon() callbacks are scheduled.) >> >> >> No, because call_soon (and call_later(0)) cause the event loop to use a >> timeout of zero on its next poll call, so a function that reschedules itself >> with call_soon will be a busy loop. There is no good way to emulate >> call_every_iteration from the other methods; you'll either busy loop with >> call_soon or use a fixed timeout. If you need it it's an easy thing to >> offer, but since neither tornado nor twisted have such a method I'm >> questioning the need. > > Yes, you're right. I was confusing things with libuv and libev. I may > have actually implemented call_soon() the wrong way there :) > > Maybe I am abusing call_every_iteration() when I use it for > dispatching. If you look at the libuv and libev documentation, then > they say that their call_every_iteration() equivalents (Prepare and > Check) are for integrating with external event loops. So maybe that is > the use case. However, I've not looked into this in any detail. > > If Tornado and Twisted cannot implement call_every_iteration(), then I > think that is a good reason to remove it. Ok, I'll kill call_every_iteration(). I'll wait for more discussion on run_once() and run()'s until-idle behavior. -- --Guido van Rossum (python.org/~guido)
- Previous message: [Python-ideas] PEP 3156 EventLoop: hide details of iterations and idleness?
- Next message: [Python-ideas] PEP 3156 EventLoop: hide details of iterations and idleness?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list