Skip to content

Can't interrupt Status._set_thread waiting for value #1262

@thopkins32

Description

@thopkins32

Problem Description

I am building a Caproto IOC which has an acquire PV like so:

@acquire.putter
async def acquire(self, instance, value):
    ...
    # Start acquisition
    if value > 0:
        if self.unsafe_to_start:
            raise RuntimeError("Acquisition cannot start because it is unsafe to do so")
    ...

Now when I connect to this PV via Ophyd and try the following, it restricts my ability to try again once it is safe to do so:

acquire = EpicsSignal("ACQUIRE", timeout=None)

acquire.set(1)  # Signal.set completes but spins up a thread that waits forever

acquire.stop_set_in_progress()  # new method to interrupt?

# Assume it is now safe to start
acquire.set(1)  # Should succeed

Without the proposed stop_set_in_progress method, the failure I get is:

RuntimeError: Another set() call is still in progress for acquire

From what I can tell, there is no way to safely stop the Signal._set_thread once it is waiting. The value will never match 1 because of the RuntimeError on the server-side. Since the timeout=None, the Signal._set_thread will be waiting forever and I have to restart Python for the next acquire.set(1) call to work.

Alternatives Considered

You could configure a shorter timeout on this EpicsSignal as a workaround, but I still think there should be a way to stop the Signal._set_thread from waiting.

You could do a EpicsSignal.put instead but then I have to monitor the readback value in my own code to ensure that the value matches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions