The Event class

class Event(security=None, needs_manual_reset=False, initially_set=False, name=None)

Bases: winsys.core._WinSysObject

An event object is an interprocess (but not intermachine) synchronisation mechanism which allows one or more threads of control to wait on others. The most common configuration is given by the defaults: anonymous, not set initially, and automatically reset once set (ie only set for long enough to release any waiting threads and then reset. A common variant is a named event which can then be referred to easily by other processes without having to pass handles around. This is why the ipc.event() function reverses the order of parameters and takes the name first.

The Event class mimics Python’s Event objects which are in any case very close to the semantics of the underlying Windows object. For that reason, although clear() is used to reset the event, reset() is also provided as an alias, matching the Windows API.

An event is Truthful if it is currently set

as_string()
clear()

Reset the event

dumped(level=0)
isSet()

Detect whether the event is currently set (by waiting without blocking)

pulse()

Cause the event to set and reset immediately

pyobject()
reset()

Reset the event

set()

Signal the event

wait(timeout_s=-1)

Wait, optionally timing out, for the event to fire. cf also the any() and all() convenience functions which take an iterable of events or other objects.

Parameters:timeout_s (float) – how many seconds to wait before timing out.
Returns:True if the event fired, False otherwise

Previous topic

The Mailslot class

Next topic

The Mutex class

This Page