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

Class Event

Lib/threading.py:584–664  ·  view source on GitHub ↗

Class implementing event objects. Events manage a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false.

Source from the content-addressed store, hash-verified

582
583
584class Event:
585 """Class implementing event objects.
586
587 Events manage a flag that can be set to true with the set() method and reset
588 to false with the clear() method. The wait() method blocks until the flag is
589 true. The flag is initially false.
590
591 """
592
593 # After Tim Peters' event class (without is_posted())
594
595 def __init__(self):
596 self._cond = Condition(Lock())
597 self._flag = False
598
599 def __repr__(self):
600 cls = self.__class__
601 status = 'set' if self._flag else 'unset'
602 return f"<{cls.__module__}.{cls.__qualname__} at {id(self):#x}: {status}>"
603
604 def _at_fork_reinit(self):
605 # Private method called by Thread._after_fork()
606 self._cond._at_fork_reinit()
607
608 def is_set(self):
609 """Return true if and only if the internal flag is true."""
610 return self._flag
611
612 def isSet(self):
613 """Return true if and only if the internal flag is true.
614
615 This method is deprecated, use is_set() instead.
616
617 """
618 import warnings
619 warnings.warn('isSet() is deprecated, use is_set() instead',
620 DeprecationWarning, stacklevel=2)
621 return self.is_set()
622
623 def set(self):
624 """Set the internal flag to true.
625
626 All threads waiting for it to become true are awakened. Threads
627 that call wait() once the flag is true will not block at all.
628
629 """
630 with self._cond:
631 self._flag = True
632 self._cond.notify_all()
633
634 def clear(self):
635 """Reset the internal flag to false.
636
637 Subsequently, threads calling wait() will block until set() is called to
638 set the internal flag to true again.
639
640 """
641 with self._cond:

Callers 9

test_contains_mutateMethod · 0.90
deccheck.pyFile · 0.90
__init__Method · 0.70
__init__Method · 0.70
enterabsMethod · 0.70

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…