yumoqing 5238a08309 perf: log system - keep file handle open + async queue writes
- Replace open/write/flush/close per log call with persistent file handle
- Use threading.Queue + background daemon thread for non-blocking writes
- Only flush on exception/critical levels or periodically (every 1s idle)
- Queue full protection: drop oldest entry instead of blocking event loop
- Eliminates disk I/O blocking on slow storage (NFS/cloud disk) during high traffic
2026-05-26 13:18:47 +08:00
..
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-08-14 15:56:52 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-09-23 10:41:55 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-18 18:37:22 +08:00
2025-07-16 11:09:20 +08:00
2026-05-16 16:44:08 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-12-11 11:00:28 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-10-14 15:28:12 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2026-02-26 11:27:08 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2026-03-27 12:01:48 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-11-28 17:56:22 +08:00
2025-10-16 12:21:17 +08:00
2025-07-16 11:09:20 +08:00
t
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2026-05-14 15:12:33 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2026-01-20 16:12:39 +08:00
2025-07-16 11:09:20 +08:00
2025-07-16 11:09:20 +08:00
2026-03-03 17:33:40 +08:00

EventDispatcher

生产级异步事件调度器。

特性

  • 支持普通函数
  • 支持 async 协程
  • 支持实例方法
  • 弱引用自动GC
  • 异常隔离
  • 超时控制
  • 自定义错误处理

使用示例

import asyncio

from event_dispatcher import EventDispatcher


def on_login(data):
    print(data)


async def main():

    dispatcher = EventDispatcher()

    dispatcher.bind(
        "login",
        on_login
    )

    await dispatcher.dispatch(
        "login",
        {
            "user": "张三"
        }
    )


asyncio.run(main())

项目结构

event_dispatcher_project/
├── event_dispatcher.py
└── README.md