Skip to main content

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


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.post2.tar.gz (11.3 kB view details)

Uploaded Source

File details

Details for the file pyeventengine-0.3.0.post2.tar.gz.

File metadata

  • Download URL: pyeventengine-0.3.0.post2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for pyeventengine-0.3.0.post2.tar.gz
Algorithm Hash digest
SHA256 4b1aa921b3e17c30d5aef7200e718b4444d097f088e98da569aaf4c8aa4e18d0
MD5 b4cc388ab6d3178a484373863c2d627d
BLAKE2b-256 0853668da70abb633272cf84127a5cc24c86355f1d4f0503f415a1b4c445f189

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page