mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
asyncio: sync with Tulip
* Document why set_result() calls are safe * Cleanup gather(). Use public methods instead of hacks to consume the exception of a future. * sock_connect(): pass directly the fd to _sock_connect_done instead of the socket.
This commit is contained in:
parent
399c59d7bd
commit
3531d9044d
3 changed files with 16 additions and 7 deletions
|
@ -582,11 +582,12 @@ def gather(*coros_or_futures, loop=None, return_exceptions=False):
|
|||
|
||||
def _done_callback(i, fut):
|
||||
nonlocal nfinished
|
||||
if outer._state != futures._PENDING:
|
||||
if fut._exception is not None:
|
||||
if outer.done():
|
||||
if not fut.cancelled():
|
||||
# Mark exception retrieved.
|
||||
fut.exception()
|
||||
return
|
||||
|
||||
if fut._state == futures._CANCELLED:
|
||||
res = futures.CancelledError()
|
||||
if not return_exceptions:
|
||||
|
@ -644,9 +645,11 @@ def shield(arg, *, loop=None):
|
|||
|
||||
def _done_callback(inner):
|
||||
if outer.cancelled():
|
||||
# Mark inner's result as retrieved.
|
||||
inner.cancelled() or inner.exception()
|
||||
if not inner.cancelled():
|
||||
# Mark inner's result as retrieved.
|
||||
inner.exception()
|
||||
return
|
||||
|
||||
if inner.cancelled():
|
||||
outer.cancel()
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue