summaryrefslogtreecommitdiffstats
path: root/Doc/library/asyncio-subprocess.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/asyncio-subprocess.rst')
-rw-r--r--Doc/library/asyncio-subprocess.rst23
1 files changed, 11 insertions, 12 deletions
diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst
index 1c1d0be..280b764 100644
--- a/Doc/library/asyncio-subprocess.rst
+++ b/Doc/library/asyncio-subprocess.rst
@@ -347,21 +347,20 @@ wait for the subprocess exit. The subprocess is created by the
def process_exited(self):
self.exit_future.set_result(True)
- @asyncio.coroutine
- def get_date(loop):
+ async def get_date(loop):
code = 'import datetime; print(datetime.datetime.now())'
exit_future = asyncio.Future(loop=loop)
# Create the subprocess controlled by the protocol DateProtocol,
# redirect the standard output into a pipe
- create = loop.subprocess_exec(lambda: DateProtocol(exit_future),
- sys.executable, '-c', code,
- stdin=None, stderr=None)
- transport, protocol = yield from create
+ transport, protocol = await loop.subprocess_exec(
+ lambda: DateProtocol(exit_future),
+ sys.executable, '-c', code,
+ stdin=None, stderr=None)
# Wait for the subprocess exit using the process_exited() method
# of the protocol
- yield from exit_future
+ await exit_future
# Close the stdout pipe
transport.close()
@@ -398,16 +397,16 @@ function::
code = 'import datetime; print(datetime.datetime.now())'
# Create the subprocess, redirect the standard output into a pipe
- create = asyncio.create_subprocess_exec(sys.executable, '-c', code,
- stdout=asyncio.subprocess.PIPE)
- proc = yield from create
+ proc = await asyncio.create_subprocess_exec(
+ sys.executable, '-c', code,
+ stdout=asyncio.subprocess.PIPE)
# Read one line of output
- data = yield from proc.stdout.readline()
+ data = await proc.stdout.readline()
line = data.decode('ascii').rstrip()
# Wait for the subprocess exit
- yield from proc.wait()
+ await proc.wait()
return line
if sys.platform == "win32":