Pyeventbus- 异步事件处理框架

网友投稿 753 2022-10-20 12:35:03

Pyeventbus- 异步事件处理框架

Pyeventbus是个十分轻巧的异步事件处理框架。

特性:

Pyeventbus 会检查你的事件消息类型和侦听器的类型的合法性,侦听器和消息需要被正确的创建 允许一个事件消息有多个对应的处理方法,事件处理的时间复杂度是O(k)的,取决于你的侦听处理函数有多少个 支持同步和异步事件处理,可自定义异步事件处理线程池大小

示例代码:

from eventbus.eventbus import EventBus#now create a eventbus,the default pool size is 4 and isdaemon is trueeventbus=EventBus()#add the listener to eventbus so it will use the right handler to process the eventeventbus.register(Listener())#now the event message were sent,eventbus will process#this is for the async posteventbus.async_post(GreetEvent())#this is for the sync posteventbus.post(GreetEvent())#remove the listenereventbus.unregister(Listener())#destroy the eventbuseventbus.destroy()

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Django REST 框架/React快速入门
下一篇:springMVC执行流程详解
相关文章