[Python-ideas] Tulip / PEP 3156 - subprocess events
Paul Moore
p.f.moore at gmail.com
Fri Jan 18 22:01:32 CET 2013
On 18 January 2013 09:33, Paul Moore <p.f.moore at gmail.com> wrote:
> [1] There is some stuff in the IOCP documentation about handles having
> to be opened in OVERLAPPED mode, which worries me here as it may imply
> that arbitrary pipes (such as the ones subprocess.Popen uses) can't be
> plugged in. It's a bit like setting a filehandle to nonblocking in
> Unix, but it has to be done at open time, IIUC. I think I saw an email
> about this that I need to hunt out.
Hmm, I'm looking at a pipe transport on Unix, and I find I don't know
enough about programming Unix. How do I set a file descriptor
(specifically a pipe) in Unix to be nonblocking? For a socket,
sock.setblocking(False) does the job. But for a pipe/file, the only
thing I can see is the O_NONBLOCK flag to os.open/os.pipe2. Is it not
possible to set an already open file descriptor to be nonblocking? If
that's the case, it means that Unix has the same problem as I suspect
exists for Windows - existing pipes and filehandles can't be used in
async code as they won't necessarily be in nonblocking mode.
Is there a way round this on Unix that I'm not aware of? Otherwise, it
seems that there's going to have to be a whole load of duplication in
the "async world" (an async version of subprocess.Popen, for a start,
as well as any other "open" type of calls that might need to produce
handles that can be used asynchronously). Either that or everything
that returns a pipe/handle that you might want to use in async code
will have to grow some sort of "async" flag.
Paul
More information about the Python-ideas
mailing list