From cc3b055ecd2954062281955c442ec89844520cee Mon Sep 17 00:00:00 2001 From: amit lissack Date: Tue, 5 Jan 2021 08:42:50 -0500 Subject: [PATCH 1/2] ProtocolManager expects a ThreadManager and not a SynchronousAdapter. --- .../session_types/protocol/execution/command_executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robot-server/robot_server/service/session/session_types/protocol/execution/command_executor.py b/robot-server/robot_server/service/session/session_types/protocol/execution/command_executor.py index 090a6fe3446..057616db504 100644 --- a/robot-server/robot_server/service/session/session_types/protocol/execution/command_executor.py +++ b/robot-server/robot_server/service/session/session_types/protocol/execution/command_executor.py @@ -89,7 +89,7 @@ def create_worker(configuration: SessionConfiguration, protocol_runner = ProtocolRunner( protocol=protocol, loop=loop, - hardware=configuration.hardware.sync, + hardware=configuration.hardware, motion_lock=configuration.motion_lock) # The async worker to which all commands are delegated. return _Worker( From bff04fa4932b8def323cc09e257d5b2e8c3bf306 Mon Sep 17 00:00:00 2001 From: amit lissack Date: Tue, 5 Jan 2021 08:57:59 -0500 Subject: [PATCH 2/2] add typing to ThreadManager.sync --- api/src/opentrons/hardware_control/thread_manager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/src/opentrons/hardware_control/thread_manager.py b/api/src/opentrons/hardware_control/thread_manager.py index 061b6212c25..a3ad835e83c 100644 --- a/api/src/opentrons/hardware_control/thread_manager.py +++ b/api/src/opentrons/hardware_control/thread_manager.py @@ -4,7 +4,7 @@ import logging import asyncio import functools -from typing import Generic, TypeVar, Any +from typing import Generic, TypeVar, Any, Optional from .adapters import SynchronousAdapter from .modules.mod_abc import AbstractModule @@ -105,7 +105,7 @@ def __init__(self, builder, *args, **kwargs): self._loop = None self.managed_obj = None self.bridged_obj = None - self._sync_managed_obj = None + self._sync_managed_obj: Optional[SynchronousAdapter] = None is_running = threading.Event() self._is_running = is_running @@ -159,8 +159,12 @@ def _build_and_start_loop(self, builder, *args, **kwargs): loop.close() @property - def sync(self): - return self._sync_managed_obj + def sync(self) -> SynchronousAdapter: + # Why the ignore? + # While self._sync_managed_obj is initialized None, a failure to build + # the managed_obj and _sync_managed_obj is a catastrophic failure. + # All callers of this property assume it to be valid. + return self._sync_managed_obj # type: ignore def __repr__(self): return ''