Feature: 优化事件分发方法 (#2067)

This commit is contained in:
Ju4tCode
2023-05-30 15:20:31 +08:00
committed by GitHub
parent 3199fc454a
commit f52abc8314
8 changed files with 728 additions and 231 deletions

View File

@ -113,8 +113,7 @@ def run_sync(call: Callable[P, R]) -> Callable[P, Coroutine[None, None, R]]:
loop = asyncio.get_running_loop()
pfunc = partial(call, *args, **kwargs)
context = copy_context()
context_run = context.run
result = await loop.run_in_executor(None, context_run, pfunc)
result = await loop.run_in_executor(None, partial(context.run, pfunc))
return result
return _wrapper
@ -139,6 +138,7 @@ async def run_sync_ctx_manager(
async def run_coro_with_catch(
coro: Coroutine[Any, Any, T],
exc: Tuple[Type[Exception], ...],
return_on_err: None = None,
) -> Union[T, None]:
...