Refactor command system to be queue based

This commit is contained in:
Alex Wolden 2025-08-21 19:08:57 -07:00
parent 2b6a4b267b
commit 28957a4b60
6 changed files with 202 additions and 30 deletions

View file

@ -1,3 +1,4 @@
from collections.abc import Coroutine
from enum import Enum
import inspect
import logging
@ -113,7 +114,7 @@ class EventDispatcher:
def subscribe(
self,
event_type: Union[EventType, None],
callback: Callable[[Event], Union[None, asyncio.Future]],
callback: Callable[[Event], Coroutine[Any, Any, None]],
attribute_filters: Optional[Dict[str, Any]] = None,
) -> Subscription:
"""
@ -226,7 +227,7 @@ class EventDispatcher:
"""
future = asyncio.Future()
def event_handler(event: Event):
async def event_handler(event: Event):
if not future.done():
future.set_result(event)