测试线程发送。防止阻塞
This commit is contained in:
@@ -26,8 +26,11 @@ def send_message_in_thread(func, *args, **kwargs):
|
|||||||
# 发送完成后停止事件循环
|
# 发送完成后停止事件循环
|
||||||
loop.stop()
|
loop.stop()
|
||||||
|
|
||||||
# 创建并运行任务,不等待结果
|
# 创建并运行任务
|
||||||
asyncio.run_coroutine_threadsafe(send(), loop)
|
asyncio.run_coroutine_threadsafe(send(), loop)
|
||||||
|
|
||||||
|
# 运行事件循环直到停止
|
||||||
|
loop.run_forever()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"线程执行失败: {e}")
|
logger.error(f"线程执行失败: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user