[Python-ideas] PEP 3156: Clarifying the different components of the event loop API

Eli Bendersky eliben at gmail.com
Sun Jan 20 15:18:02 CET 2013


On Sat, Jan 19, 2013 at 6:34 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> PEP 3156 currently lists *29* proposed methods for the event loop API.
> These methods serve quite different purposes and I think a bit more
> structure in the overall API could help clarify that.
>
> First proposal: clearly split the abstract EventLoop API from concrete
> DescriptorEventLoop and IOCPEventLoop subclasses.


> The main benefit here is to help clarify that:
> 1. the additional methods defined on DescriptorEventLoop and
> IOCPEventLoop are not available on all event loop implementations, so
> any code using them is necessarily event loop specific
> 2. the goal of the transport abstraction is to mask the differences
> between these low level platform specific APIs
> 3. other event loops are free to use a completely different API
> between their low level transports and the event loop
>
>
I like the idea of splitting up the big interface, but could you clarify
what would go into such subclasses? I.e. isn't the current EventLoop
interface supposed to represent an interface all event loops will adhere to?

And sorry if this was discussed before and I'm missing the context, but
what kinds of EventLoop implementations are we expecting to see eventually?
Is it only a matter of implementing the API per platform (akin to the
current tulip.unix_events.UnixEventLoop) or a broader expectation of
frameworks like Twisted to plug into the API by providing their own
implementation (PEP 3156 mentions this somewhere).


> Second proposal: better separate the "event loop management", "event
> monitoring" and "do things" methods
>

<snip>

>
> Do things (and get the result with "yield from"):
> - wrap_future() # Perhaps "wrap_executor_future"?
> - run_in_executor()
> - getaddrinfo()
> - getnameinfo()
>
> Low level transport creation:
> - create_connection()
> - create_pipe() # Once it exists in the PEP
>
>
+1 These certainly look somewhat out of place in the generic EventLoop API,
but concretely - how do you propose to structure the split?

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130120/0ab05cc8/attachment.html>


More information about the Python-ideas mailing list