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

Class Event

Lib/multiprocessing/synchronize.py:335–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333#
334
335class Event(object):
336
337 def __init__(self, *, ctx):
338 self._cond = ctx.Condition(ctx.Lock())
339 self._flag = ctx.Semaphore(0)
340
341 def is_set(self):
342 with self._cond:
343 if self._flag.acquire(False):
344 self._flag.release()
345 return True
346 return False
347
348 def set(self):
349 with self._cond:
350 self._flag.acquire(False)
351 self._flag.release()
352 self._cond.notify_all()
353
354 def clear(self):
355 with self._cond:
356 self._flag.acquire(False)
357
358 def wait(self, timeout=None):
359 with self._cond:
360 if self._flag.acquire(False):
361 self._flag.release()
362 else:
363 self._cond.wait(timeout)
364
365 if self._flag.acquire(False):
366 self._flag.release()
367 return True
368 return False
369
370 def __repr__(self):
371 set_status = 'set' if self.is_set() else 'unset'
372 return f"<{type(self).__qualname__} at {id(self):#x} {set_status}>"
373#
374# Barrier
375#

Callers 1

EventMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…