Skip to content

Commit

Permalink
fix(robot-server): ProtocolManager expects a ThreadManager and not a …
Browse files Browse the repository at this point in the history
…SynchronousAdapter. (#7175)

* ProtocolManager expects a ThreadManager and not a SynchronousAdapter.
* add typing to ThreadManager.sync
  • Loading branch information
amitlissack authored Jan 5, 2021
1 parent 4cab53f commit c0c9225
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions api/src/opentrons/hardware_control/thread_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 '<ThreadManager>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c0c9225

Please sign in to comment.