Calling asyncio.run_coroutine_threadsafe across different event loops
Calling asyncio.run_coroutine_threadsafe across different event loops Question: I have a class inside a microservice that looks like this: import asyncio import threading class A: def __init__(self): self.state = [] self._flush_thread = self._start_flush() self.tasks = set() def _start_flush(self): threading.Thread(target=self._submit_flush).start() def _submit_flush(self): self._thread_loop = asyncio.new_event_loop() self._thread_loop.run_until_complete(self.flush_state()) # async def regular_func(self): # This function is called on an …