From f8047fa2615c5866dbce9e9a6adfe8f2044e72a8 Mon Sep 17 00:00:00 2001 From: amit lissack Date: Tue, 26 Oct 2021 11:56:37 -0400 Subject: [PATCH] progress. --- .../emulation/module_server/client.py | 1 + .../opentrons/hardware_control/emulation/settings.py | 2 +- g-code-testing/g_code_parsing/g_code_engine.py | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/api/src/opentrons/hardware_control/emulation/module_server/client.py b/api/src/opentrons/hardware_control/emulation/module_server/client.py index bf60164a1f9a..f0f6652e6fa0 100644 --- a/api/src/opentrons/hardware_control/emulation/module_server/client.py +++ b/api/src/opentrons/hardware_control/emulation/module_server/client.py @@ -42,6 +42,7 @@ async def connect( for i in range(retries): try: r, w = await asyncio.open_connection(host=host, port=port) + break except OSError: await asyncio.sleep(interval_seconds) diff --git a/api/src/opentrons/hardware_control/emulation/settings.py b/api/src/opentrons/hardware_control/emulation/settings.py index 8e62cfc1192d..192847393a48 100644 --- a/api/src/opentrons/hardware_control/emulation/settings.py +++ b/api/src/opentrons/hardware_control/emulation/settings.py @@ -29,7 +29,7 @@ class ModuleServerSettings(BaseModel): """Settings for the module server""" host: str = "0.0.0.0" - port: int = 8888 + port: int = 8989 class Settings(BaseSettings): diff --git a/g-code-testing/g_code_parsing/g_code_engine.py b/g-code-testing/g_code_parsing/g_code_engine.py index 3b48a6b82ecc..63ef0203b6f7 100644 --- a/g-code-testing/g_code_parsing/g_code_engine.py +++ b/g-code-testing/g_code_parsing/g_code_engine.py @@ -62,14 +62,14 @@ def _get_loop() -> asyncio.AbstractEventLoop: @staticmethod def _start_emulation_app(emulator_settings: Settings) -> Process: """Start emulated OT-2""" - modules = [ModuleType.Thermocycler, ModuleType.Temperature, ModuleType.Magnetic] + modules = [ModuleType.Magnetic, ModuleType.Temperature, ModuleType.Thermocycler] - def runit(): + def _run_app(): asyncio.run( run_app.run(emulator_settings, modules=[m.value for m in modules]) ) - proc = Process(target=runit) + proc = Process(target=_run_app) proc.daemon = True proc.start() @@ -80,7 +80,11 @@ async def _wait_ready() -> None: await wait_emulators(client=c, modules=modules, timeout=5) c.close() - ready_proc = Process(target=lambda: asyncio.run(_wait_ready())) + def _run_wait_ready(): + asyncio.run(_wait_ready()) + + ready_proc = Process(target=_run_wait_ready) + ready_proc.daemon = True ready_proc.start() ready_proc.join()