diff --git a/hardware/opentrons_hardware/drivers/can_bus/can_messenger.py b/hardware/opentrons_hardware/drivers/can_bus/can_messenger.py index fd2973dfccb..02d8e0bec06 100644 --- a/hardware/opentrons_hardware/drivers/can_bus/can_messenger.py +++ b/hardware/opentrons_hardware/drivers/can_bus/can_messenger.py @@ -352,7 +352,7 @@ async def _read_task_shield(self) -> None: while True: try: await self._read_task() - except asyncio.CancelledError: + except (asyncio.CancelledError, StopAsyncIteration): return except (CANCommunicationError, AsyncHardwareError, CanError) as e: log.exception(f"Nonfatal error in CAN read task: {e}") @@ -389,6 +389,7 @@ async def _read_task(self) -> None: log.exception(f"Failed to build from {message}") else: log.error(f"Message {message} is not recognized.") + raise StopAsyncIteration async def _handle_error(self, build: BinarySerializable) -> None: err_msg = ErrorMessage(payload=build) # type: ignore[arg-type]