极简事件系统(处理程序包)
visitoolkit-eventsystem的Python项目详细描述
VisiToolkit事件系统
极简事件系统
通过pip安装
https://pypi.org/project/visitoolkit-eventsystem
(在Python 3上运行)
说明
当事件被触发时被调用的注册处理程序(处理程序包)
使用“axel事件”中的思想https://github.com/axel-events/axel
以及来自http://www.valuedlessons.com/2008/04/events-in-python.html的“事件系统”
用法
fromvisitoolkit_eventsystemimporteventsystem# handlers are callback functions in your code,# when firing an event visitoolkit_eventsystem will call them with the given argument(s)defcb1(event_id,*arg,**args):ifevent_id>0:# handle event...returnTrueelse:returnFalse# 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 occurredes=eventsystem.EventSystem(sync_mode=True)# adding or removing handlers in list-like syntaxes+=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 eventresult=es(42)
提高错误查找的日志记录级别:
importlogginglogging.getLogger('visitoolkit_eventsystem').setLevel(logging.DEBUG)
背景资料
visitolkit\u eventsystem在visitolkit\u连接器中用作visitolkit的核心部分。
visitolkit是为专有的构建和过程管理系统编写的
“促销(C)MST SystemTechnik AG”
(也称为“SAIA Visi.Plus”(C)SAIA Burgess控制公司)
意图:
支持可视化项目的创建者…
提高效率…
减少容易出错的手动过程…
添加缺少的功能…
免责声明:使用“visitolkit”的风险自负