Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a870c9

Browse files
committed
asyncio: sync with Tulip
- Tulip issue #181: Faster create_connection(). Call directly waiter.set_result() in the constructor of _ProactorBasePipeTransport and _SelectorSocketTransport, instead of using of delaying the call with call_soon(). - Cleanup iscoroutine()
1 parent 11116da commit 1a870c9

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/asyncio/coroutines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ def iscoroutinefunction(func):
166166
return getattr(func, '_is_coroutine', False)
167167

168168

169-
_COROUTINE_TYPES = (CoroWrapper, types.GeneratorType)
169+
_COROUTINE_TYPES = (types.GeneratorType, CoroWrapper)
170170

171171
def iscoroutine(obj):
172172
"""Return True if obj is a coroutine object."""
173-
return isinstance(obj, _COROUTINE_TYPES)
173+
return isinstance(obj, _COROUTINE_TYPES)
174174

175175

176176
def _format_coroutine(coro):

Lib/asyncio/proactor_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, loop, sock, protocol, waiter=None,
3838
self._server.attach(self)
3939
self._loop.call_soon(self._protocol.connection_made, self)
4040
if waiter is not None:
41-
self._loop.call_soon(waiter._set_result_unless_cancelled, None)
41+
waiter.set_result(None)
4242

4343
def _set_extra(self, sock):
4444
self._extra['pipe'] = sock

Lib/asyncio/selector_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def __init__(self, loop, sock, protocol, waiter=None,
481481
self._loop.add_reader(self._sock_fd, self._read_ready)
482482
self._loop.call_soon(self._protocol.connection_made, self)
483483
if waiter is not None:
484-
self._loop.call_soon(waiter._set_result_unless_cancelled, None)
484+
waiter.set_result(None)
485485

486486
def pause_reading(self):
487487
if self._closing:

0 commit comments

Comments
 (0)