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

Method add_done_callback

Lib/concurrent/futures/_base.py:402–420  ·  view source on GitHub ↗

Attaches a callable that will be called when the future finishes. Args: fn: A callable that will be called with this future as its only argument when the future completes or is cancelled. The callable will always be called by a thread in the same

(self, fn)

Source from the content-addressed store, hash-verified

400 return self._result
401
402 def add_done_callback(self, fn):
403 """Attaches a callable that will be called when the future finishes.
404
405 Args:
406 fn: A callable that will be called with this future as its only
407 argument when the future completes or is cancelled. The callable
408 will always be called by a thread in the same process in which
409 it was added. If the future has already completed or been
410 cancelled then the callable will be called immediately. These
411 callables are called in the order that they were added.
412 """
413 with self._condition:
414 if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]:
415 self._done_callbacks.append(fn)
416 return
417 try:
418 fn(self)
419 except Exception:
420 LOGGER.exception('exception calling callback for %r', self)
421
422 def result(self, timeout=None):
423 """Return the result of the call that the future represents.

Callers

nothing calls this directly

Calls 3

fnFunction · 0.85
appendMethod · 0.45
exceptionMethod · 0.45

Tested by

no test coverage detected