Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
SystemEvent
provides a simple synchronization primitive for use across multiple
processes. The SystemEvent
object emulates the threading.Event
API exactly. In
addition, simple scripts (evt_set
, evt_wait
, and evt_clear
) are installed for
easy usage from shell scripts.
The main reason to use SystemEvent
is in situations when you want processes to wait
on other processes without the need for polling.
pip install SystemEvent
SystemEvent
uses named posix semaphores under the hood, so you need to choose event
names that are unique to your application. Any event references will use this unique name.
From Python, use it exactly like you would use a
threading.Event
instances, with the main difference being that you need to give your event a name so that other processes can reference it.
For example, in as many consoles as you like, set up an event and have it wait (the last line will block on each ```wait()`` call):
>>> import SystemEvent
>>> evt = SystemEvent.SystemEvent("my_event")
>>> evt.wait()
Alternatively, you can just run evt_wait my_event
from your favorite shell (this is
just a small script that does the above almost exactly).
In another console, set the event and note that the first event releases:
>>> import SystemEvent
>>> evt = SystemEvent.SystemEvent("my_event")
>>> evt.set()
All events blocking on "my_event" will be immediately released by this set()
call.
Subsequent calls to evt.wait()
from any process will not block, since the event is now
globally latched.
To clear the event (so that calls to evt.wait()
will block again), call
evt.clear()
.
As with threading.Event
(and multiprocessing.Event
) there is also an isSet()
method which tells you the current state (but watch out for race conditions when checking
it).
Three shell scripts are provided, with the following usage:
evt_wait <event_name> [timeout_s]
evt_set <event_name>
evt_clear <event_name>
These scripts are thin shells over SystemEvent
usage. The timeout_s
option on
evt_wait
is optional, and defaults to infinity.
All scripts have an exit code of 0, unless evt_wait
times out, in which case it
returns 1.
SystemEvent
currently uses a posix semaphore internally. To integrate with other
non-python applications, you can just access the same named semaphore. Just be careful
that you increment and decrement correctly. Check out the code for details... it is
ridiculously small.
MIT. See LICENSE
file.
posix_ipc
requirementFAQs
System-wide Event synchonization for posix (emulating the threading.Event api)
We found that SystemEvent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.