diff --git a/pw_transfer/py/pw_transfer/client.py b/pw_transfer/py/pw_transfer/client.py index 27c5459598..30d7d86a85 100644 --- a/pw_transfer/py/pw_transfer/client.py +++ b/pw_transfer/py/pw_transfer/client.py @@ -74,6 +74,9 @@ def __init__(self, self._write_stream: Optional[BidirectionalStreamingCall] = None self._loop = asyncio.new_event_loop() + # If constructed from non-main thread, set the event loop. + if threading.current_thread() is not threading.main_thread(): + asyncio.set_event_loop(self._loop) # Queues are used for communication between the Manager context and the # dedicated asyncio transfer thread.