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

Paul Moore p.f.moore at gmail.com
Tue Jan 22 16:43:51 CET 2013


On 22 January 2013 13:34, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Also, I agree with the comment someone else made that attempting to
> pair stdin with either stderr or stdout is a bad idea - better to
> treat them as three independent transports (as the subprocess module
> does), so that the close() semantics and error handling are clear.

That was my original feeling - although I made my case badly by
arguing in terms of portability rather than clearer design. But Guido
argued for a higher-level portable subprocess transport that was
implemented "under the hood" using the existing nonportable
add_reader/add_writer methods on Unix, and an as-yet-unimplemented
IOCP-based alternative on Windows.

I still feel that a more general approach would be to have two methods
on the event loop connect_input_pipe(protocol_factory, readable_pipe)
and connect_output_pipe(protocol_factory, writeable_pipe) which use
the standard transport/protocol methods as defined in the PEP. Then
the subprocess transport can be layered on top of that as one possible
example of a "higher layer" convenience transport.

I know that twisted has a create_process event loop (reactor) method,
but I suspect part of the reason for that is that it predates the
subprocess module's unified interface.

I'll try implementing the pipe transport approach and see how it looks
in contrast.

Paul.



More information about the Python-ideas mailing list