PyVents is a powerful Python library for events
Project description
PyVents
PyVents is a powerful Python library for events.
Features
Installation
Using pip:
pip install pyvents
Using Poetry:
poetry add pyvents
Getting-Started
See examples for more.
Simple
from pyvents import Event
event = Event("myevent")
def subscriber():
print("Called subscriber")
def main():
event.subscribe(subscriber)
event.publish()
# Called subscriber
if __name__ == '__main__':
main()
Advanced
import threading
import asyncio
from pyvents import (
AsyncEvent,
Event,
EventChannel,
ThreadedEvent,
)
class MyEventChannel(EventChannel):
event = Event()
async_event = AsyncEvent()
threaded_event = ThreadedEvent()
@MyEventChannel.event.subscribe
def subscriber():
print("Called subscriber")
@MyEventChannel.async_event.subscribe
async def async_subscriber():
print("Called async_subscriber")
@MyEventChannel.threaded_event.subscribe
def threaded_subscriber():
print("Called threaded_subscriber")
print(f"Current thread: {threading.current_thread()}")
async def main():
MyEventChannel.event.publish()
# Called subscriber
await MyEventChannel.async_event.publish_async()
# Called async_subscriber
MyEventChannel.threaded_event.publish_threaded()
# Called threaded_subscriber
# Current thread: <Thread(Thread-1 (threaded_subscriber), started xxxx)>
if __name__ == "__main__":
asyncio.run(main())
Status
0.0.1
- RELEASED
License
PyVents is released under the MIT License. See the bundled LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyvents-0.0.1.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file pyvents-0.0.1.tar.gz
.
File metadata
- Download URL: pyvents-0.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cc66b3d5dfa5b18e0701048c5708edbfc0753cd56debe63e69df6f31685865a |
|
MD5 | 9f162674130e11f51eab5070ea903e6c |
|
BLAKE2b-256 | b67612e1658214c3be19ffe3129a33fbd543c1bea1092e393d60fa7e032befa3 |
File details
Details for the file pyvents-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pyvents-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26972bfce7a4967342e1ba09abcd6f739d0200e29fe15e2291ec58762ed02afc |
|
MD5 | bdcdb7e66803386f4ad440868ce1af9f |
|
BLAKE2b-256 | 8b7726571720eea2138de9e412ccd6a4948e6f002dc8dc8aa877c82156e49967 |