From 2c83a1943a548f61aff786edbfc927ce2318dd06 Mon Sep 17 00:00:00 2001 From: Ryan Howard Date: Thu, 16 Nov 2023 16:02:54 -0500 Subject: [PATCH] Add back in the aexit hook but start the server as an orphaned process instead so python releases everything before the server tries to lock it (#14010) --- .../hardware_testing/opentrons_api/helpers_ot3.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py b/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py index 6652a174a73..cd442e3e170 100644 --- a/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py +++ b/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py @@ -4,10 +4,10 @@ from datetime import datetime from enum import Enum from math import pi -from subprocess import run +from subprocess import run, Popen from time import time from typing import Callable, Coroutine, Dict, List, Optional, Tuple, Union - +import atexit from opentrons_hardware.drivers.can_bus import DriverSettings, build, CanMessenger from opentrons_hardware.drivers.can_bus import settings as can_bus_settings from opentrons_hardware.firmware_bindings.constants import SensorId @@ -77,6 +77,15 @@ def stop_server_ot3() -> None: """Stop opentrons-robot-server on the OT3.""" print('Stopping "opentrons-robot-server"...') run(["systemctl", "stop", "opentrons-robot-server"]) + atexit.register(restart_server_ot3) + + +def restart_server_ot3() -> None: + """Start opentrons-robot-server on the OT3.""" + print('Starting "opentrons-robot-server"...') + Popen( + ["systemctl", "restart", "opentrons-robot-server", "&"], + ) def start_server_ot3() -> None: