MCPcopy Index your code
hub / github.com/python/cpython / _cancel_and_wait

Function _cancel_and_wait

Lib/asyncio/tasks.py:537–551  ·  view source on GitHub ↗

Cancel the *fut* future or task and wait until it completes.

(fut)

Source from the content-addressed store, hash-verified

535
536
537async def _cancel_and_wait(fut):
538 """Cancel the *fut* future or task and wait until it completes."""
539
540 loop = events.get_running_loop()
541 waiter = loop.create_future()
542 cb = functools.partial(_release_waiter, waiter)
543 fut.add_done_callback(cb)
544
545 try:
546 fut.cancel()
547 # We cannot wait on *fut* directly to make
548 # sure _cancel_and_wait itself is reliably cancellable.
549 await waiter
550 finally:
551 fut.remove_done_callback(cb)
552
553
554class _AsCompletedIterator:

Callers 1

wait_forFunction · 0.85

Calls 5

partialMethod · 0.80
create_futureMethod · 0.45
add_done_callbackMethod · 0.45
cancelMethod · 0.45
remove_done_callbackMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…