This release is a pre-release and may not be stable for production use.
ThreadingValueEvent
A thread synchronization primitive for Python like threading.Event, but instead of just a
boolean flag, it carries any Python value. Threads can wait for a value to be set, retrieve it, and optionally reset the
event for reuse.
Features
- Wait for an event to be set, optionally with a timeout.
- Pass any Python object (not just a boolean) from one thread to another.
- Ability to clear/reset the event.
- Intuitive, event-like API.
Installation
pip install threading-value-event
Usage
from __future__ import print_function
from threading_value_event import ThreadingValueEvent
import threading
import time
event = ThreadingValueEvent()
def worker():
print('Worker waiting for value...')
result = event.wait()
print('Worker got:', result)
thread = threading.Thread(target=worker)
thread.start()
time.sleep(1)
print('Main thread setting value to 123.')
event.set(123)
thread.join()
Output:
Worker waiting for value...
Main thread setting value to 123.
Worker got: 123
API
ThreadingValueEvent()
Create a new event object.
set(value)
Set the event, storing value. Wakes up all threads waiting for this event.
is_set()
Return True if the event is set, else False.
wait(timeout=None, default=None)
Block until the event is set, then return the value. If a timeout is provided and the event isn't set in time, returns
default.
clear()
Clear the event and remove the stored value.
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the License.
Release files for threading-value-event 0.1.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| threading_value_event-0.1.0a0.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| threading_value_event-0.1.0a0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 6.8 kB
Release files / threading_value_event-0.1.0a0.tar.gz
| Download URL | threading_value_event-0.1.0a0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
651d3764282af37370324c9c8dad28258198163db2e6c87c0cb90f4ae92b18dd
|
|
BLAKE2b-256 checksum How to use checksums |
9edc2b685fd341f61e4d81d060be22b5d75e90273bf54908c560a570aed21144
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / threading_value_event-0.1.0a0-py2.py3-none-any.whl
| Download URL | threading_value_event-0.1.0a0-py2.py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fa26428a9d91a1792af1f9b00ce981c825b48027028491c847655707010aff6b
|
|
BLAKE2b-256 checksum How to use checksums |
d42782ad4d113e9b26332e599b1a0a1b266b959cadb1d2a80073011e379573e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|