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

Class Event

Lib/threading.py:591–671  ·  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

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

Callers 4

__init__Method · 0.70
__init__Method · 0.70
enterabsMethod · 0.70

Calls

no outgoing calls

Tested by 1