diff --git a/docker-examples/client/simple_events/client.py b/docker-examples/client/simple_events/client.py index e747295..4949435 100644 --- a/docker-examples/client/simple_events/client.py +++ b/docker-examples/client/simple_events/client.py @@ -44,7 +44,7 @@ async def main_loop(): control_connection = TCP(host, port) blob_connection = TCP(host, port) - def client_callback(event): + async def client_callback(event): print(event) client = Client(control_connection, blob_connection) diff --git a/indi/client/client.py b/indi/client/client.py index d2e38df..05448b9 100644 --- a/indi/client/client.py +++ b/indi/client/client.py @@ -302,7 +302,10 @@ def trigger_event(self, event: events.BaseEvent): for callback in self.callbacks: if callback.accepts_event(event): try: - callback.callback(event) + if asyncio.iscoroutinefunction(callback.callback): + asyncio.get_running_loop().create_task(callback.callback(event)) + else: + callback.callback(event) except: logger.exception("Error in event handler")