1
0
forked from bot/app

新增on_keywords

This commit is contained in:
2024-08-22 09:35:02 +08:00
parent a3a31a2c94
commit 4bf8512a7d
12 changed files with 137 additions and 22 deletions

View File

@ -5,6 +5,7 @@
import asyncio
import inspect
import multiprocessing
import threading
from pathlib import Path
from typing import Any, Callable, Coroutine
@ -61,6 +62,16 @@ def run_coroutine(*coro: Coroutine):
# 捕获其他异常,防止协程被重复等待
logger.error(f"Exception occurred: {e}")
def run_coroutine_in_thread(*coro: Coroutine):
"""
在新线程中运行协程
Args:
coro:
Returns:
"""
threading.Thread(target=run_coroutine, args=coro, daemon=True).start()
def path_to_module_name(path: Path) -> str:
"""