You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement op.done(error="msg") for failed put operations on command and write PVs #303
We have found that doing op.done(error="msg") for a command results in a pop up dialogue box, but doing the same for WritePvs does not. Both cases result in a log to the phoebus command line of the error message. We should investigate why this occurs, and check if we can prevent the pop up for commands, such that we can implement op.done(error="msg") appropriately.
Acceptance Criteria
Specific criteria that will be used to judge if the issue is fixed
I've been investigating FastCS at my new place!
There seems to be weird behaviour in general with exceptions, maybe tangential to this issue though. For PVA:
Here, the PV is posted before the IO is done. It also always calls op.done() without giving any exception info. This means that the hardware can fail to do the set, but the PV will still update, and the client will have no error info
The CommandPVHandler, on a failed command, posts op.done() with no exception information, it does put the PV into an alarm state, but a PVA client still won't know that the put failed unless it reads the PV again at a later point.
CA also doesn't seem to propagate exceptions back to the client.
I think we should always do the actual hardware IO in a try except block before doing pv.post. If there's an exception, log it, and then pass it into op.done(error=str(error)) so that the client is aware. Also depending on the exception, put the PV into an alarm state. Does that sound right @shihab-dls ? If yes, I can do the fix
I've been investigating FastCS at my new place! There seems to be weird behaviour in general with exceptions, maybe tangential to this issue though. For PVA:
* [Here](https://github.com/DiamondLightSource/fastcs/blob/8c54354f57b91fab8320bf2e7e2b7dd3d2e58c66/src/fastcs/transports/epics/pva/_pv_handlers.py#L51), the PV is posted before the IO is done. It also always calls `op.done()` without giving any exception info. This means that the hardware can fail to do the set, but the PV will still update, and the client will have no error info
* The `CommandPVHandler`, on a failed command, posts `op.done()` with no exception information, it does put the PV into an alarm state, but a PVA client still won't know that the put failed unless it reads the PV again at a later point.
CA also doesn't seem to propagate exceptions back to the client.
I think we should always do the actual hardware IO in a try except block before doing pv.post. If there's an exception, log it, and then pass it into op.done(error=str(error)) so that the client is aware. Also depending on the exception, put the PV into an alarm state. Does that sound right @shihab-dls ? If yes, I can do the fix
I think this is definitely a bug, but the ordering of the operations is intentional. The intended path is we pv.post on our write PV, then we try except the hardware IO, then we do an op.done(error=msg). This way we have a setpoint with the intended value, a readback value which has not been updated (as the hardware IO failed), and an exception on the operation that propagates up. As you mentioned, CommandPVHandler does the right thing of setting the PV into alarm, but this should be done for WritePvHandler as well, where we collect our alarm states based on an self._attr_w.put(cast_value) exception.
On CA, we don't have the same concept of op.done. So we can't pass up a message readily. However, if the on_update callback on the CA record fails, the record should go into alarm (a try except block with record.set_alarm would work), which is a flag that can be used to check state.
This bug affects bluesky/ophyd-async#1315, which I've just picked up, so I can pick this up now!
Activity
olliesilvester commentedon Jun 29, 2026
I've been investigating FastCS at my new place!
There seems to be weird behaviour in general with exceptions, maybe tangential to this issue though. For PVA:
op.done()without giving any exception info. This means that the hardware can fail to do the set, but the PV will still update, and the client will have no error infoCommandPVHandler, on a failed command, postsop.done()with no exception information, it does put the PV into an alarm state, but a PVA client still won't know that the put failed unless it reads the PV again at a later point.CA also doesn't seem to propagate exceptions back to the client.
I think we should always do the actual hardware IO in a try except block before doing
pv.post. If there's an exception, log it, and then pass it intoop.done(error=str(error))so that the client is aware. Also depending on the exception, put the PV into an alarm state. Does that sound right @shihab-dls ? If yes, I can do the fixshihab-dls commentedon Jul 13, 2026
I think this is definitely a bug, but the ordering of the operations is intentional. The intended path is we
pv.poston our write PV, then we try except the hardware IO, then we do anop.done(error=msg). This way we have a setpoint with the intended value, a readback value which has not been updated (as the hardware IO failed), and an exception on the operation that propagates up. As you mentioned,CommandPVHandlerdoes the right thing of setting the PV into alarm, but this should be done forWritePvHandleras well, where we collect our alarm states based on anself._attr_w.put(cast_value)exception.On CA, we don't have the same concept of
op.done. So we can't pass up a message readily. However, if theon_updatecallback on the CA record fails, the record should go into alarm (a try except block withrecord.set_alarmwould work), which is a flag that can be used to check state.This bug affects bluesky/ophyd-async#1315, which I've just picked up, so I can pick this up now!