[Python-ideas] async: feedback on EventLoop API

Antoine Pitrou solipsis at pitrou.net
Tue Dec 18 08:29:55 CET 2012


On Mon, 17 Dec 2012 20:01:18 -0800
Guido van Rossum <guido at python.org> wrote:
> [Multiple calls per FD]
> >> That makes sense. If we wanted to be fancy we could have several
> >> different APIs: add (must not be set), set (may be set), replace (must
> >> be set). But I think just offering the add and remove APIs is nicely
> >> minimalistic and lets you do everything else with ease. (I'll make the
> >> remove API return True if it did remove something, False otherwise.)
> 
> > Perhaps the best bet would be to have the standard API allow multiple
> > callbacks, and emulate that on systems which don't natively support multiple
> > callbacks for a single event?
> 
> Hm. AFAIK Twisted doesn't support this either. Antoine, do you know? I
> didn't see it in the Tornado event loop either.

I think neither Twisted nor Tornado support it. add_reader() /
add_writer() APIs are not for the end user, they are a building block
for the framework to write higher-level abstractions.
(although, Tornado being quite low-level, you can end up having to use
add_reader() / add_writer() anyway - e.g. for UDP)

It also doesn't seem to me to make a lot of sense to allow multiplexing
at the event loop level. It is probably a protocol- or transport- level
feature (depending on the protocol and transport, obviously :-)).

Nick mentions debugging / monitoring, but I don't understand how you do
that with a write callback (or a read callback, actually, since
reading from a socket will consume the data and make it unavailable
for other readers). You really need to do it at a protocol/transport's
write()/data_received() level.

Regards

Antoine.





More information about the Python-ideas mailing list