[Python-Dev] Status of PEP 3145 (original) (raw)

[Python-Dev] Status of PEP 3145 - Asynchronous I/O for subprocess.popen

Victor Stinner victor.stinner at gmail.com
Fri Mar 28 00:11:00 CET 2014


Hi,

2014-03-27 22:52 GMT+01:00 Josiah Carlson <josiah.carlson at gmail.com>:

... but I never made an effort to get it practically working with asyncore - primarily because such would be functionally impossible on Windows without a lot of work to pull in a chunk of what was pywin32 libraries (at the time, Windows was a primary target). On the *nix side of things, performing the integration would be arguably trivial as select, poll, epoll, etc., all deal with pipes the same way as any other file handles (on-disk files, domain sockets, network sockets, etc.), with OS X being the exception.

You should definitively take a look at asyncio. It handles sockets and pipes on all platforms, and even character devices (PTY) on some platforms. (The current status is still unclear to me, especially regarding to the "non blocking" flag of the PTY.) On Windows, asyncio uses IOCP.

asyncio.subprocess solves also an old issue related to polling: subprocess.wait(timeout) uses polling because it was not possible to register an handler for SIGCHLD handler without breaking backward compatibility. asyncio supports also signals as well.

As an alternative, easily 95% of what most people would use this for can be written as an example using the asyncio module and included in the docs just after (or replacing) http://docs.python.org/3/library/asyncio-subprocess.html#example . Adding a reference to the subprocess module docs to point off to the asyncio subprocess example docs would get people a copy/paste snippet that they can include and update to their heart's content.

Yeah, a link should be added from the subprocess module to the asyncio.subprocess module (the module, not the example). FYI the asyncore doc now has this note:

"Note: This module exists for backwards compatibility only. For new code we recommend using asyncio."

I opened the following issue for the "ls | wc -l" feature request: http://bugs.python.org/issue21080

Victor



More information about the Python-Dev mailing list