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

Method cancel

Lib/concurrent/futures/_base.py:358–375  ·  view source on GitHub ↗

Cancel the future if possible. Returns True if the future was cancelled, False otherwise. A future cannot be cancelled if it is running or has already completed.

(self)

Source from the content-addressed store, hash-verified

356 _STATE_TO_DESCRIPTION_MAP[self._state])
357
358 def cancel(self):
359 """Cancel the future if possible.
360
361 Returns True if the future was cancelled, False otherwise. A future
362 cannot be cancelled if it is running or has already completed.
363 """
364 with self._condition:
365 if self._state in [RUNNING, FINISHED]:
366 return False
367
368 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
369 return True
370
371 self._state = CANCELLED
372 self._condition.notify_all()
373
374 self._invoke_callbacks()
375 return True
376
377 def cancelled(self):
378 """Return True if the future was cancelled."""

Callers 4

_result_or_cancelFunction · 0.45
result_iteratorMethod · 0.45
shutdownMethod · 0.45

Calls 2

_invoke_callbacksMethod · 0.95
notify_allMethod · 0.45

Tested by

no test coverage detected