update emc start/shutdown, initial emc tests

This commit is contained in:
Timothy Pogue
2022-09-10 12:51:29 -06:00
parent d8cdd92140
commit 866a564958
3 changed files with 97 additions and 8 deletions

View File

@@ -90,16 +90,16 @@ class ExternalMessageConsumer:
"""
Start the main internal loop in another thread to run coroutines
"""
if self._thread and self._loop:
return
logger.info("Starting ExternalMessageConsumer")
self._loop = asyncio.new_event_loop()
self._thread = Thread(target=self._loop.run_forever)
self._thread.start()
if not self._thread:
logger.info("Starting ExternalMessageConsumer")
self._thread = Thread(target=self._loop.run_forever)
self._thread.start()
self._running = True
else:
raise RuntimeError("A loop is already running")
self._running = True
self._main_task = asyncio.run_coroutine_threadsafe(self._main(), loop=self._loop)
@@ -121,6 +121,11 @@ class ExternalMessageConsumer:
self._thread.join()
self._thread = None
self._loop = None
self._sub_tasks = None
self._main_task = None
async def _main(self):
"""
The main task coroutine