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

Uploaded Source

Built Distribution

PyEventEngine-0.3.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pyeventengine-0.3.2.tar.gz.

File metadata

  • Download URL: pyeventengine-0.3.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pyeventengine-0.3.2.tar.gz
Algorithm Hash digest
SHA256 d72d91c5e9f94d04912877f6792e42310f9c21ba7c7491d6b52e8fba3888c68b
MD5 96aed3f141c278f07c7737c40e0dccd1
BLAKE2b-256 46df9f6d5a21858f1bbedda24bcd070b92800b67cb9f7861bfb14ce6267b721b

See more details on using hashes here.

Provenance

File details

Details for the file PyEventEngine-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for PyEventEngine-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea6073d32e585091e16649336a693e9251b889d23a37e1631117e1a8740c4905
MD5 8b2915c0a69f5909dec155e19ce0d9fa
BLAKE2b-256 dfb26bb80d44390e35ace9d69ed48f98e7bde8d63cb5f4284c765b531bf7f3a9

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