[Python-ideas] Tulip / PEP 3156 (original) (raw)
[Python-ideas] Tulip / PEP 3156 - subprocess events
Nick Coghlan ncoghlan at gmail.com
Tue Jan 22 14:34:48 CET 2013
- Previous message: [Python-ideas] Tulip / PEP 3156 - subprocess events
- Next message: [Python-ideas] Tulip / PEP 3156 - subprocess events
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jan 22, 2013 at 10:03 PM, Paul Moore <p.f.moore at gmail.com> wrote:
So, a question: If the user passed a popen object without a stdin pipe, should writeeof be an error or should it just silently do nothing?
It should be an error. The analogy is similar to calling flush() vs close(). Calling flush() on an already closed file is an error, while you can call close() as many times as you like.
If you want to ensure a pipe is closed gracefully, call close(), not write_eof(). (abort() is the method for abrupt closure).
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.
sockets are different, as those actually are bidirectional data streams, whereas pipes are unidirectional.
I don't know whether it's worth defining separate SimplexTransmit (e.g. stdin pipe in parent process, stdout, stderr pipes in child process), SimplexReceive (stdout, stderr pipes in parent process, stdin pip in child process), HalfDuplex (e.g. some radio transmitters) and FullDuplex (e.g. sockets) transport abstractions - I guess if Twisted haven't needed them, it probably isn't worth bothering. It's also fairly obvious how to implement the first three based on the full duplex API currently described in the PEP just be raising the appropriate exceptions.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-ideas] Tulip / PEP 3156 - subprocess events
- Next message: [Python-ideas] Tulip / PEP 3156 - subprocess events
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]