[Python-ideas] Tulip / PEP 3156 - subprocess events
Paul Moore
p.f.moore at gmail.com
Thu Jan 17 13:23:10 CET 2013
On 16 January 2013 18:21, Guido van Rossum <guido at python.org> wrote:
>> OK, off to do a lot of spec reading and then some coding. With luck,
>> you'll be patient with dumb questions from me on the way :-)
>
> I will be!
OK, I'm reading the PEP through now. I'm happy with the basics of the
event loop, and it seems fine to me. When I reached create_transport,
I had to skip ahead to the definitions of transport and protocol, as
create_transport makes no sense if you don't know about those. Once
I've read that, though, the whole transport/protocol mechanism seems
to make reasonable sense to me. Although the host and port arguments
to create_transport are clearly irrelevant to the case of a transport
managing a process as a data source. So (a) I see why you say I'd need
a new transport creation method, but (b) it strikes me that something
more general that covered both cases (and any others that may come up
later) would be better.
On the other hand, given the existence of create_transport, I'm now
struggling to understand why a user would ever use
add_reader/add_writer rather than using a transport/protocol. And if
they do have a reason to do so, why does a similar reason not apply to
having an add_pipe type of method for waiting on (subprocess) pipes?
In general, it still feels to me like the socket use case is being
treated as "special", and other data sources and sinks (subprocesses
being my use case, but I'm sure others exist) are either second-class
or require a whole set of their own specialised methods, which isn't
practical.
As a strawman type of argument in favour of extensibility, consider a
very specialist user with a hardware device that sends input via (say)
a serial port. I can easily imagine that user wanting to plug his
device data into the Python event loop. As this is a very specialised
area, I wouldn't expect the core code to be able to help, but I would
expect him to be able to write code that plugs into the standard event
loop seamlessly. Ideally, I'd like to use the subprocess case as a
proof that this is practical.
Does that make sense?
Paul.
More information about the Python-ideas
mailing list