minimalistic event system (a bag of handlers)
Project description
visitoolkit_eventsystem
minimalistic event system migrated to Python 3 and separated as standalone PyPI package
description
Registered handlers (a bag of handlers) getting called when event gets fired
using ideas from "axel events" https://github.com/axel-events/axel
and "event system" from http://www.valuedlessons.com/2008/04/events-in-python.html
usage
import visitoolkit_eventsystem.eventsystem as eventsystem
# handlers are callback functions in your code,
# when firing an event visitoolkit_eventsystem will call them with the given argument(s)
def cb1(event_id, *arg, **args):
if event_id > 0:
# handle event...
return True
else:
return False
# Default is synchronous execution of handlers (blocking main thread, collecting all results)
# sync_mode=False means asynchronous execution of handlers (one background thread calls all handlers)
# =>Details about flag "exc_info"(default is True): https://docs.python.org/3/library/sys.html#sys.exc_info
# =>Flag "traceback" (default is False) controls verbosity of error_info when an exception occurred
es = eventsystem.EventSystem(sync_mode=True)
# adding or removing handlers in list-like syntax
es += cb1
#The execution result is returned as a list containing all results per handler having this structure:
# exec_result = [
# (True, result, handler), # on success
# (False, error_info, handler), # on error
# (None, None, handler), ... # asynchronous execution
# ]
# firing event
result = es(42)
background information
visitoolkit_eventsystem is used in visitoolkit_connector as core part of visitoolkit.
visitoolkit is written for the proprietary Building and Process Management System
'ProMoS NT' (c) MST Systemtechnik AG'
(also known as 'Saia Visi.Plus' (c) Saia-Burgess Controls AG)
Intention:
Support creator of visualisation projects...
Add efficiency...
Reduce manual error-prone processes...
Add missing features...
Disclaimer: Use 'visitoolkit' at your own risk!
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
Built Distribution
Hashes for visitoolkit-eventsystem-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45018be488b28aba04b7f56efd5e9355e8323d0f13552aa1dd1219e715c660ea |
|
MD5 | b127b4d0cbb5be18f4e6b55677eb5cb4 |
|
BLAKE2b-256 | 3dda038c4cd644bb6ebf883ff22dd82146e79b12f11a4ab9b79b7f95960a7464 |
Hashes for visitoolkit_eventsystem-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c47519f00d811eb94e7867b3a9cf1a47dc8a8c0ff53d359587f010c54c93148b |
|
MD5 | c2cc8a8794d7c6d9ff1cd78d73808537 |
|
BLAKE2b-256 | 4e46f9c8d4ab42a6280a773f24bfe9a2e7944508d7ecf35f3c967b0a547a79cc |