summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2017-12-08 22:23:48 (GMT)
committerGitHub <noreply@github.com>2017-12-08 22:23:48 (GMT)
commit5f841b553814969220b096a2b4f959b7f6fcbaf6 (patch)
treeb48ea916d9585efa9bf7ff370b50c4e2dfb30247 /Lib/asyncio/selector_events.py
parentede157331b4f9e550334900b3b4de1c8590688de (diff)
downloadcpython-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/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 3639466..c30fde7 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -24,7 +24,6 @@ from . import events
from . import futures
from . import transports
from . import sslproto
-from .coroutines import coroutine
from .log import logger
@@ -189,9 +188,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
sslcontext, server)
self.create_task(accept)
- @coroutine
- def _accept_connection2(self, protocol_factory, conn, extra,
- sslcontext=None, server=None):
+ async def _accept_connection2(self, protocol_factory, conn, extra,
+ sslcontext=None, server=None):
protocol = None
transport = None
try:
@@ -207,7 +205,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
server=server)
try:
- yield from waiter
+ await waiter
except:
transport.close()
raise
@@ -452,8 +450,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
fd = sock.fileno()
self.add_writer(fd, self._sock_sendall, fut, fd, sock, data)
- @coroutine
- def sock_connect(self, sock, address):
+ async def sock_connect(self, sock, address):
"""Connect to a remote socket at address.
This method is a coroutine.
@@ -465,12 +462,12 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
resolved = base_events._ensure_resolved(
address, family=sock.family, proto=sock.proto, loop=self)
if not resolved.done():
- yield from resolved
+ await resolved
_, _, _, _, address = resolved.result()[0]
fut = self.create_future()
self._sock_connect(fut, sock, address)
- return (yield from fut)
+ return await fut
def _sock_connect(self, fut, sock, address):
fd = sock.fileno()