Skip to content

Derived signal timeout bug #1231

@jacob720

Description

@jacob720

I wrote a device for the cobra on i15-1 which uses a derived signal to move it between a safe and beam position, which takes ~30s. I found when I do bps.abs_set(derived_signal, value) which sets the underlying motor, I get a timeout error (see https://graylog.diamond.ac.uk/messages/graylog-prod_19/99066f52-2934-11f1-a66b-22d3eb5a3de6). This seemed to happen after 10s of the move.

This happened even if I gave long timeouts to the motor set call inside the set_derived function. If I just set the motor directly, I don't get this error so it seems like something to do with the derived signal. This is how I wrote the device:

class Cobra(StandardReadable):
    def __init__(self, prefix: str):
        self.motor = Motor(prefix=prefix)
        self.position = derived_signal_rw(
            self._get_position,
            self._set_position,
            current_position=self.motor,
        )
        self._safe_position = 2.0
        self._beam_position = 100.0
        super().__init__(prefix)

    def _get_position(self, current_position: float) -> CobraPosition:
        if current_position == self._safe_position:
            return CobraPosition.SAFE
        elif current_position == self._beam_position:
            return CobraPosition.BEAM
        raise ValueError(
            f"Device's position {current_position} is not {CobraPosition.SAFE}: "
            f"{self._safe_position} or {CobraPosition.BEAM}: {self._beam_position}"
        )

    async def _set_position(self, position: CobraPosition):
        if position == CobraPosition.SAFE:
            await self.motor.set(self._safe_position, 60)
        elif position == CobraPosition.BEAM:
            await self.motor.set(self._beam_position, 60)
yield from bps.abs_set(cobra.position, CobraPosition.SAFE, group=group)  # TimeoutError
yield from bps.abs_set(cobra.motor, 2.0, group=group)  # works

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Create a derived signal who's set method takes longer than 10s
  2. Call bps.abs_set on the derived signal.

Acceptance Criteria

  • You can have a derived signal who's set method takes longer than 10s

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions