Basic event engine
Project description
PyEventEngine
python native event engine
Install
pip install git+https://github.com/BolunHan/PyEventEngine.git
or
pip install PyEventEngine
Use
basic usage
# init event engine
import time
from event_engine import EventEngine, Topic
EVENT_ENGINE = EventEngine()
EVENT_ENGINE.start()
# register handler
def test_handler(msg, **kwargs):
print(msg)
EVENT_ENGINE.register_handler(topic=Topic('SimpleTopic'), handler=test_handler)
# publish message
EVENT_ENGINE.put(topic=Topic('SimpleTopic'), msg='topic called')
time.sleep(1)
EVENT_ENGINE.stop()
regular topic
# init event engine
import time
from event_engine import EventEngine, Topic, RegularTopic
EVENT_ENGINE = EventEngine()
EVENT_ENGINE.start()
# register handler
def test_handler(msg, **kwargs):
print(msg)
EVENT_ENGINE.register_handler(topic=RegularTopic('RegularTopic.*'), handler=test_handler)
# publish message
EVENT_ENGINE.put(topic=Topic('RegularTopic.ChildTopic0'), msg='topic called')
time.sleep(1)
EVENT_ENGINE.stop()
timer topic
# init event engine
import time
from event_engine import EventEngine, Topic, RegularTopic
EVENT_ENGINE = EventEngine()
EVENT_ENGINE.start()
# register handler
def test_handler(**kwargs):
print(kwargs)
topic = EVENT_ENGINE.get_timer(interval=1)
EVENT_ENGINE.register_handler(topic=topic, handler=test_handler)
# publish message
time.sleep(5)
EVENT_ENGINE.stop()
See more advanced usage at .Demo
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
PyEventEngine-0.3.0.post5.tar.gz
(11.5 kB
view details)
File details
Details for the file PyEventEngine-0.3.0.post5.tar.gz
.
File metadata
- Download URL: PyEventEngine-0.3.0.post5.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0574a8c49e4bbcb2d74c1def8d469051490987cab6800cbdc2fac67f530f39b1 |
|
MD5 | a48c15e466e673ca05905f30df2d6193 |
|
BLAKE2b-256 | a31b9702f1b632fdf05d274ed1be1bf854f8ded3585636ccb2343383e9d51a0e |