From 6663d5655b6376e6cd90b1af9f897c48845d68b2 Mon Sep 17 00:00:00 2001 From: pmoegenburg Date: Wed, 24 Aug 2022 19:49:20 -0400 Subject: [PATCH 1/2] updated locking --- .../hardware_control/modules/heater_shaker.py | 7 +++--- .../hardware_control/modules/update.py | 25 ++++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/api/src/opentrons/hardware_control/modules/heater_shaker.py b/api/src/opentrons/hardware_control/modules/heater_shaker.py index 88537137bca..64127ca76a9 100644 --- a/api/src/opentrons/hardware_control/modules/heater_shaker.py +++ b/api/src/opentrons/hardware_control/modules/heater_shaker.py @@ -442,10 +442,9 @@ async def close_labware_latch(self) -> None: async def prep_for_update(self) -> str: await self._poller.stop_and_wait() - async with update.protect_dfu_transition(): - await self._driver.enter_programming_mode() - dfu_info = await update.find_dfu_device(pid=DFU_PID) - return dfu_info + await self._driver.enter_programming_mode() + dfu_info = await update.find_dfu_device(pid=DFU_PID) + return dfu_info @dataclass diff --git a/api/src/opentrons/hardware_control/modules/update.py b/api/src/opentrons/hardware_control/modules/update.py index 73678738800..e9a34cc759e 100644 --- a/api/src/opentrons/hardware_control/modules/update.py +++ b/api/src/opentrons/hardware_control/modules/update.py @@ -29,18 +29,19 @@ async def update_firmware( raises an UpdateError with the reason for the failure. """ - flash_port_or_dfu_serial = await module.prep_for_update() - kwargs: Dict[str, Any] = { - "stdout": asyncio.subprocess.PIPE, - "stderr": asyncio.subprocess.PIPE, - "loop": loop, - } - successful, res = await module.bootloader()( - flash_port_or_dfu_serial, str(firmware_file), kwargs - ) - if not successful: - log.info(f"Bootloader reponse: {res}") - raise UpdateError(res) + async with protect_dfu_transition(): + flash_port_or_dfu_serial = await module.prep_for_update() + kwargs: Dict[str, Any] = { + "stdout": asyncio.subprocess.PIPE, + "stderr": asyncio.subprocess.PIPE, + "loop": loop, + } + successful, res = await module.bootloader()( + flash_port_or_dfu_serial, str(firmware_file), kwargs + ) + if not successful: + log.info(f"Bootloader reponse: {res}") + raise UpdateError(res) async def find_bootloader_port() -> str: From c6645643e2eba9b38f4a5d14b5c1fd3d6928074a Mon Sep 17 00:00:00 2001 From: pmoegenburg Date: Wed, 24 Aug 2022 20:08:27 -0400 Subject: [PATCH 2/2] updated naming --- api/src/opentrons/hardware_control/modules/update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/opentrons/hardware_control/modules/update.py b/api/src/opentrons/hardware_control/modules/update.py index e9a34cc759e..e43117bb6fd 100644 --- a/api/src/opentrons/hardware_control/modules/update.py +++ b/api/src/opentrons/hardware_control/modules/update.py @@ -11,12 +11,12 @@ log = logging.getLogger(__name__) -_dfu_transition_lock = ThreadedAsyncLock() +_update_transition_lock = ThreadedAsyncLock() @asynccontextmanager -async def protect_dfu_transition() -> AsyncGenerator[None, None]: - async with _dfu_transition_lock.lock(): +async def protect_update_transition() -> AsyncGenerator[None, None]: + async with _update_transition_lock.lock(): yield @@ -29,7 +29,7 @@ async def update_firmware( raises an UpdateError with the reason for the failure. """ - async with protect_dfu_transition(): + async with protect_update_transition(): flash_port_or_dfu_serial = await module.prep_for_update() kwargs: Dict[str, Any] = { "stdout": asyncio.subprocess.PIPE,