MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / Event

Class Event

tools/python-3.11.9-amd64/Lib/threading.py:551–630  ·  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

549
550
551class Event:
552 """Class implementing event objects.
553
554 Events manage a flag that can be set to true with the set() method and reset
555 to false with the clear() method. The wait() method blocks until the flag is
556 true. The flag is initially false.
557
558 """
559
560 # After Tim Peters' event class (without is_posted())
561
562 def __init__(self):
563 self._cond = Condition(Lock())
564 self._flag = False
565
566 def __repr__(self):
567 cls = self.__class__
568 status = 'set' if self._flag else 'unset'
569 return f"<{cls.__module__}.{cls.__qualname__} at {id(self):#x}: {status}>"
570
571 def _at_fork_reinit(self):
572 # Private method called by Thread._reset_internal_locks()
573 self._cond._at_fork_reinit()
574
575 def is_set(self):
576 """Return true if and only if the internal flag is true."""
577 return self._flag
578
579 def isSet(self):
580 """Return true if and only if the internal flag is true.
581
582 This method is deprecated, use is_set() instead.
583
584 """
585 import warnings
586 warnings.warn('isSet() is deprecated, use is_set() instead',
587 DeprecationWarning, stacklevel=2)
588 return self.is_set()
589
590 def set(self):
591 """Set the internal flag to true.
592
593 All threads waiting for it to become true are awakened. Threads
594 that call wait() once the flag is true will not block at all.
595
596 """
597 with self._cond:
598 self._flag = True
599 self._cond.notify_all()
600
601 def clear(self):
602 """Reset the internal flag to false.
603
604 Subsequently, threads calling wait() will block until set() is called to
605 set the internal flag to true again.
606
607 """
608 with self._cond:

Callers 5

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.70
__init__Method · 0.70
enterabsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected