From 309b9adf343bc755b32d222030aa91c20fc4b729 Mon Sep 17 00:00:00 2001 From: GreyElaina Date: Sun, 9 Jul 2023 12:10:54 +0800 Subject: [PATCH] feat: DispatcherInterface.exec_result --- src/graia/broadcast/__init__.py | 3 ++- src/graia/broadcast/interfaces/dispatcher.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graia/broadcast/__init__.py b/src/graia/broadcast/__init__.py index 40b3f30..34b4508 100644 --- a/src/graia/broadcast/__init__.py +++ b/src/graia/broadcast/__init__.py @@ -188,7 +188,7 @@ async def Executor( if i: await run_always_await(i, dii, None, None) - result = await run_always_await(target_callable, **parameter_compile_result) + dii.exec_result.set_result(await run_always_await(target_callable, **parameter_compile_result)) except (ExecutionStop, PropagationCancelled): raise except RequirementCrashed as e: @@ -233,6 +233,7 @@ async def Executor( dii.ctx.reset(dii_token) + result = dii.exec_result.result() if result.__class__ is Force: return result.target elif result is RemoveMe: diff --git a/src/graia/broadcast/interfaces/dispatcher.py b/src/graia/broadcast/interfaces/dispatcher.py index 8c90099..2d2deb1 100644 --- a/src/graia/broadcast/interfaces/dispatcher.py +++ b/src/graia/broadcast/interfaces/dispatcher.py @@ -11,6 +11,7 @@ Union, ) +from asyncio import Future from ..entities.event import Dispatchable from ..entities.signatures import Force from ..exceptions import ExecutionStop, RequirementCrashed @@ -47,6 +48,7 @@ class DispatcherInterface(Generic[T_Event]): } ctx: "ClassVar[Ctx[DispatcherInterface]]" = Ctx("bcc_dii") + exec_result: Future[Any] broadcast: "Broadcast" dispatchers: List[T_Dispatcher] @@ -66,6 +68,7 @@ def __init__(self, broadcast_instance: "Broadcast", dispatchers: List[T_Dispatch self.current_path = NestableIterable([]) self.current_oplog = [] self.success = set() + self.exec_result = Future() self._depth = depth @property