Skip to content

Commit

Permalink
fix(robot-server): fix a merge race condition. (#6030)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitlissack authored Jun 29, 2020
1 parent b626f67 commit 628049c
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import typing
from opentrons.hardware_control import ThreadManager

from . import Command, CompletedCommand, complete_command
from . import Command, CompletedCommand
from . base_executor import CommandExecutor
from .command import CommandResult
from ..errors import UnsupportedCommandException
from ..models import CommandDataType, CommandName
from robot_server.util import duration


COMMAND_HANDLER = typing.Callable[
Expand Down Expand Up @@ -44,12 +46,18 @@ def __init__(self,
async def execute(self, command: Command) -> CompletedCommand:
func = self.get_handler(command.content.name)
if func:
await func(self._hardware, command.content.data)
with duration() as timed:
await func(self._hardware, command.content.data)
else:
raise UnsupportedCommandException(
f"Command '{command.content.name}' is not supported."
)
return complete_command(command, "executed")
return CompletedCommand(
content=command.content,
meta=command.meta,
result=CommandResult(started_at=timed.start,
completed_at=timed.end)
)

def get_handler(self, command_name: CommandName) \
-> typing.Optional[COMMAND_HANDLER]:
Expand Down

0 comments on commit 628049c

Please sign in to comment.