[Python-ideas] Tulip / PEP 3156 - subprocess events

Paul Moore p.f.moore at gmail.com
Fri Jan 18 23:32:17 CET 2013


On 18 January 2013 21:24, Guido van Rossum <guido at python.org> wrote:
>> To create that create_corba_connection() function, you'd be expected
>> to subclass the standard event loop, is that right?
>
> No, it doesn't need to be a method on the event loop at all. It can
> just be a function in a different package; it can use
> events.get_current_event_loop() to reference the event loop.

Aargh. I'm confused again! (I did warn you about dumb questions, didn't I? :-))

The event loop implementation contains the code that does the OS-level
poll for events to process. (In tulip, that is handled by the selector
object, but that's not mentioned in the PEP so I assume it should be
considered an implementation detail). So, the event loop has to define
what types of (OS-level) objects can be registered. At the moment,
event loops only handle sockets (via select/poll/etc) and even the raw
add_reader methods are not for end user use.

So a standalone create_corba_connection function can certainly get the
event loop using get_current_event_loop(), but it has no means of
asking the event loop to poll the CORBA connection it creates for new
messages. Without direct access to the selector (or equivalent) it
can't add the extra event source. (Unless that source is a pollable
file descriptor and it's willing to play with the optional add_reader
methods, but that's not a "new event source" then...) The same problem
will likely occur if you try to integrate Windows GUI events (you
check for a GUI message by calling a Windows API).

I don't think this matters except in obscure cases (it's likely a huge
case of YAGNI) but I genuinely don't understand how you can say that
create_corba_connection() could be written as a standalone function,
and yet that create_connection() has to be a method of the event loop.
That's what I'm getting at when I keep saying that I see you treating
sockets as "special". There's clearly something I'm missing in your
thinking, and it keeps tripping me up.

Paul.



More information about the Python-ideas mailing list