mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Refactor command system to be queue based
This commit is contained in:
parent
2b6a4b267b
commit
28957a4b60
6 changed files with 202 additions and 30 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue