MCPcopy Index your code
hub / github.com/RustPython/RustPython / set_running_or_notify_cancel

Method set_running_or_notify_cancel

Lib/concurrent/futures/_base.py:497–535  ·  view source on GitHub ↗

Mark the future as running or process any cancel notifications. Should only be used by Executor implementations and unit tests. If the future has been cancelled (cancel() was called and returned True) then any threads waiting on the future completing (though calls t

(self)

Source from the content-addressed store, hash-verified

495
496 # The following methods should only be used by Executors and in tests.
497 def set_running_or_notify_cancel(self):
498 """Mark the future as running or process any cancel notifications.
499
500 Should only be used by Executor implementations and unit tests.
501
502 If the future has been cancelled (cancel() was called and returned
503 True) then any threads waiting on the future completing (though calls
504 to as_completed() or wait()) are notified and False is returned.
505
506 If the future was not cancelled then it is put in the running state
507 (future calls to running() will return True) and True is returned.
508
509 This method should be called by Executor implementations before
510 executing the work associated with this future. If this method returns
511 False then the work should not be executed.
512
513 Returns:
514 False if the Future was cancelled, True otherwise.
515
516 Raises:
517 RuntimeError: if this method was already called or if set_result()
518 or set_exception() was called.
519 """
520 with self._condition:
521 if self._state == CANCELLED:
522 self._state = CANCELLED_AND_NOTIFIED
523 for waiter in self._waiters:
524 waiter.add_cancelled(self)
525 # self._condition.notify_all() is not necessary because
526 # self.cancel() triggers a notification.
527 return False
528 elif self._state == PENDING:
529 self._state = RUNNING
530 return True
531 else:
532 LOGGER.critical('Future %s in unexpected state: %s',
533 id(self),
534 self._state)
535 raise RuntimeError('Future in unexpected state')
536
537 def set_result(self, result):
538 """Sets the return value of work associated with the future.

Callers 4

callbackFunction · 0.80
runMethod · 0.80

Calls 3

idFunction · 0.85
add_cancelledMethod · 0.45
criticalMethod · 0.45

Tested by

no test coverage detected