Skip to content

Commit

Permalink
feat: DispatcherInterface.exec_result
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyElaina committed Jul 9, 2023
1 parent 12a2c71 commit 309b9ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/graia/broadcast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/graia/broadcast/interfaces/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Union,
)

from asyncio import Future
from ..entities.event import Dispatchable
from ..entities.signatures import Force
from ..exceptions import ExecutionStop, RequirementCrashed
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit 309b9ad

Please sign in to comment.