Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(robot-server): ProtocolManager expects a ThreadManager and not a SynchronousAdapter. #7175

Merged
merged 2 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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