diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-01-04 02:17:15 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-01-04 02:17:15 +0100 |
commit | 28a47539dd977b4499cbe1d2aafb784c6bb5f198 (patch) | |
tree | 2e812418771ee8165bfaa4a281ce1e82f8b6d76f | |
parent | 3c5af1dbdd56ad60a1def806012c39a2668e7648 (diff) | |
download | trollius-28a47539dd977b4499cbe1d2aafb784c6bb5f198.tar.gz |
_UnixSubprocessTransport._start() now uses the makefile() method when available
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | asyncio/tasks.py | 1 | ||||
-rw-r--r-- | asyncio/unix_events.py | 13 |
3 files changed, 10 insertions, 5 deletions
@@ -5,6 +5,7 @@ - test_queues.py - test_tasks.py +* as_completed() is a coroutine or not? * Move asyncio/coroutine.py in asyncio/tasks.py? * Fix coroutine._DEBUG=True * Fix all FIXME in the code diff --git a/asyncio/tasks.py b/asyncio/tasks.py index 0538f63..25003bf 100644 --- a/asyncio/tasks.py +++ b/asyncio/tasks.py @@ -372,7 +372,6 @@ def _wait(fs, timeout, return_when, loop): # This is *not* a @coroutine! It is just an iterator (yielding Futures). -# FIXME: @coroutine def as_completed(fs, loop=None, timeout=None): """Return an iterator whose values, when waited for, are Futures. diff --git a/asyncio/unix_events.py b/asyncio/unix_events.py index ab17558..0cfbd5f 100644 --- a/asyncio/unix_events.py +++ b/asyncio/unix_events.py @@ -403,10 +403,15 @@ class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport): universal_newlines=False, bufsize=bufsize, **kwargs) if stdin_w is not None: stdin.close() - # FIXME: use socket.makefile("rb", bufsize)? - stdin_dup = os.dup(stdin_w.fileno()) - stdin_w.close() - self._proc.stdin = os.fdopen(stdin_dup, 'rb', bufsize) + if hasattr(stdin_w, 'detach'): + stdin_fd = stdin_w.detach() + self._proc.stdin = os.fdopen(stdin_fd, 'rb', bufsize) + elif hasattr(stdin_w, 'makefile'): + self._proc.stdin = stdin_w.makefile('rb', bufsize) + else: + stdin_dup = os.dup(stdin_w.fileno()) + stdin_w.close() + self._proc.stdin = os.fdopen(stdin_dup, 'rb', bufsize) class AbstractChildWatcher(object): |