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

Method notify

Lib/threading.py:408–436  ·  view source on GitHub ↗

Wake up one or more threads waiting on this condition, if any. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the threads waiting for the condition variable; it is a no-op if no

(self, n=1)

Source from the content-addressed store, hash-verified

406 return result
407
408 def notify(self, n=1):
409 """Wake up one or more threads waiting on this condition, if any.
410
411 If the calling thread has not acquired the lock when this method is
412 called, a RuntimeError is raised.
413
414 This method wakes up at most n of the threads waiting for the condition
415 variable; it is a no-op if no threads are waiting.
416
417 """
418 if not self._is_owned():
419 raise RuntimeError("cannot notify on un-acquired lock")
420 waiters = self._waiters
421 while waiters and n > 0:
422 waiter = waiters[0]
423 try:
424 waiter.release()
425 except RuntimeError:
426 # gh-92530: The previous call of notify() released the lock,
427 # but was interrupted before removing it from the queue.
428 # It can happen if a signal handler raises an exception,
429 # like CTRL+C which raises KeyboardInterrupt.
430 pass
431 else:
432 n -= 1
433 try:
434 waiters.remove(waiter)
435 except ValueError:
436 pass
437
438 def notify_all(self):
439 """Wake up all threads waiting on this condition.

Callers 5

notify_allMethod · 0.95
releaseMethod · 0.45
releaseMethod · 0.45
putMethod · 0.45
getMethod · 0.45

Calls 3

_is_ownedMethod · 0.95
releaseMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected