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

Function _copy_future_state

Lib/asyncio/futures.py:355–370  ·  view source on GitHub ↗

Internal helper to copy state from another Future. The other Future must be a concurrent.futures.Future.

(source, dest)

Source from the content-addressed store, hash-verified

353
354
355def _copy_future_state(source, dest):
356 """Internal helper to copy state from another Future.
357
358 The other Future must be a concurrent.futures.Future.
359 """
360 if dest.cancelled():
361 return
362 assert not dest.done()
363 done, cancelled, result, exception = source._get_snapshot()
364 assert done
365 if cancelled:
366 dest.cancel()
367 elif exception is not None:
368 dest.set_exception(_convert_future_exc(exception))
369 else:
370 dest.set_result(result)
371
372def _chain_future(source, destination):
373 """Chain two futures so that when one completes, so does the other.

Callers 3

test_copy_stateMethod · 0.90
_set_stateFunction · 0.85

Calls 7

_convert_future_excFunction · 0.85
_get_snapshotMethod · 0.80
cancelledMethod · 0.45
doneMethod · 0.45
cancelMethod · 0.45
set_exceptionMethod · 0.45
set_resultMethod · 0.45

Tested by 2

test_copy_stateMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…