diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2017-12-08 22:23:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-08 22:23:48 (GMT) |
commit | 5f841b553814969220b096a2b4f959b7f6fcbaf6 (patch) | |
tree | b48ea916d9585efa9bf7ff370b50c4e2dfb30247 /Lib/asyncio/base_subprocess.py | |
parent | ede157331b4f9e550334900b3b4de1c8590688de (diff) | |
download | cpython-5f841b553814969220b096a2b4f959b7f6fcbaf6.zip cpython-5f841b553814969220b096a2b4f959b7f6fcbaf6.tar.gz cpython-5f841b553814969220b096a2b4f959b7f6fcbaf6.tar.bz2 |
bpo-32193: Convert asyncio to async/await usage (#4753)
* Convert asyncio/tasks.py to async/await
* Convert asyncio/queues.py to async/await
* Convert asyncio/test_utils.py to async/await
* Convert asyncio/base_subprocess.py to async/await
* Convert asyncio/subprocess.py to async/await
* Convert asyncio/streams.py to async/await
* Fix comments
* Convert asyncio/locks.py to async/await
* Convert asyncio.sleep to async def
* Add a comment
* Add missing news
* Convert stubs from AbstrctEventLoop to async functions
* Convert subprocess_shell/subprocess_exec
* Convert connect_read_pipe/connect_write_pip to async/await syntax
* Convert create_datagram_endpoint
* Convert create_unix_server/create_unix_connection
* Get rid of old style coroutines in unix_events.py
* Convert selector_events.py to async/await
* Convert wait_closed and create_connection
* Drop redundant line
* Convert base_events.py
* Code cleanup
* Drop redundant comments
* Fix indentation
* Add explicit tests for compatibility between old and new coroutines
* Convert windows event loop to use async/await
* Fix double awaiting of async function
* Convert asyncio/locks.py
* Improve docstring
* Convert tests to async/await
* Convert more tests
* Convert more tests
* Convert more tests
* Convert tests
* Improve test
Diffstat (limited to 'Lib/asyncio/base_subprocess.py')
-rw-r--r-- | Lib/asyncio/base_subprocess.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py index cac8d96..7e5a901 100644 --- a/Lib/asyncio/base_subprocess.py +++ b/Lib/asyncio/base_subprocess.py @@ -4,7 +4,6 @@ import warnings from . import protocols from . import transports -from .coroutines import coroutine from .log import logger @@ -154,26 +153,25 @@ class BaseSubprocessTransport(transports.SubprocessTransport): self._check_proc() self._proc.kill() - @coroutine - def _connect_pipes(self, waiter): + async def _connect_pipes(self, waiter): try: proc = self._proc loop = self._loop if proc.stdin is not None: - _, pipe = yield from loop.connect_write_pipe( + _, pipe = await loop.connect_write_pipe( lambda: WriteSubprocessPipeProto(self, 0), proc.stdin) self._pipes[0] = pipe if proc.stdout is not None: - _, pipe = yield from loop.connect_read_pipe( + _, pipe = await loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 1), proc.stdout) self._pipes[1] = pipe if proc.stderr is not None: - _, pipe = yield from loop.connect_read_pipe( + _, pipe = await loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 2), proc.stderr) self._pipes[2] = pipe @@ -224,8 +222,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): waiter.set_result(returncode) self._exit_waiters = None - @coroutine - def _wait(self): + async def _wait(self): """Wait until the process exit and return the process return code. This method is a coroutine.""" @@ -234,7 +231,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport): waiter = self._loop.create_future() self._exit_waiters.append(waiter) - return (yield from waiter) + return await waiter def _try_finish(self): assert not self._finished |