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
changed the title [-]run_task doesn't work, hangs until it times out, but also doesn't respect timeout[/-][+]run_task/blueapi cli client doesn't work, hangs until it times out, but also doesn't respect timeout[/+]on Oct 10, 2025
changed the title [-]run_task/blueapi cli client doesn't work, hangs until it times out, but also doesn't respect timeout[/-][+]run_task/blueapi hangs until it times out, but also doesn't respect timeout[/+]on Oct 10, 2025
changed the title [-]run_task/blueapi hangs until it times out, but also doesn't respect timeout[/-][+]run_task/blueapi hangs until it times out[/+]on Nov 4, 2025
Can I ask what you are trying to do/why you are implementing this using time.sleep ? I don't know exactly what is happening without digging into it, but since this is a blocking call on that thread its a good candidate for shenanigans. If I know what you are trying to achieve we can do it in a way that works better with the eco-system.
Can I ask what you are trying to do/why you are implementing this using time.sleep ? I don't know exactly what is happening without digging into it, but since this is a blocking call on that thread its a good candidate for shenanigans. If I know what you are trying to achieve we can do it in a way that works better with the eco-system.
You get the same behaviour with from dodal.plan_stubs.wrapped import sleep - if that's what you're wondering.
The sleep is just there just to stop requests coming in too frequently, in case that was an issue.
I'm trying to give a blueapi scripting interface for the beamline scientist for commissioning purposes. If I can give them the building blocks of the system, then they should have everything they need to start using it in ernest
No useful logs in graylog, however on the client side I get the following error:
Silence this message by starting a CA repeater daemon
or by calling ca_pend_event() and or ca_poll() more often.
WARNING:root:Stomp connection lost, will attempt reconnection with policy StompReconnectPolicy(initial_delay=0.0, attempt_period=10.0)
and in the BlueAPI logs I get (which looks normal) but never proceeds to the next iterations of the loop:
2025-11-28 11:48:37,333 INFO Submitting: task_id='1c43f535-6825-4875-87e7-c8e3da33a226' task=Task(name='log_detectors', params={}, metadata={'instrument_session': 'cm40643-5'}) request_id=None is_complete=False is_pending=True errors=[]
2025-11-28 11:48:37,334 INFO Got new task: task_id='1c43f535-6825-4875-87e7-c8e3da33a226' task=Task(name='log_detectors', params={}, metadata={'instrument_session': 'cm40643-5'}) request_id=None is_complete=False is_pending=True errors=[]
2025-11-28 11:48:37,334 INFO Asked to run plan log_detectors with {} and metadata {'instrument_session': 'cm40643-5'} for all runs
2025-11-28 11:48:37,334 INFO Executing plan <generator object log_detectors at 0x7fe9650971c0>
2025-11-28 11:48:37,334 INFO Change state on <bluesky.run_engine.RunEngine object at 0x7fe965d96850> from 'idle' -> 'running'
2025-11-28 11:48:37,335 INFO None
2025-11-28 11:48:37,335 INFO Change state on <bluesky.run_engine.RunEngine object at 0x7fe965d96850> from 'running' -> 'idle'
2025-11-28 11:48:37,335 INFO Cleaned up from plan <generator object log_detectors at 0x7fe9650971c0>
2025-11-28 11:48:37,336 INFO Awaiting task
2025-11-28 11:48:37,573 INFO method: POST url: http://i22-blueapi.diamond.ac.uk/tasks body: b'{"name": "log_detectors", "params": {}, "instrument_session": "cm40643-5"}'
2025-11-28 11:48:37,575 WARNING Invalid correlation id detected: None
Also anecdotally it is a) worse during the day (died on about the 3 iter), compared to at night (5th iter) b) better during shutdown, c) better on a tuesday shutdown d) much better when the water leak happened (15th iter)
So yes, this is the same thing as we've seen a few times on i04. This is a high priority issue for MX too - until it's resolved it means we shouldn't really leave BlueAPI on a UDC beamline.
I've been digging into this and while I can't reproduce it from the example you have above, I did find a couple of related issues. I'm not sure if either is causing it on its own but it would be good to test with them fixed to check if they resolve this issue.
The closest I could get to reproducing the problem was by stopping activemq while a scan was running - mainly inspired by the Stomp connection lost message you were getting in the client.
The stomp client doesn't reliably reconnect
When the activemq service is restarted, the client never seems to reconnect to it meaning it never gets the 'task complete' message and waits indefinitely. This is potentially fixed by Catch and wrap unexpected connection errors bluesky-stomp#45 . With this patch included, the client can re-connect and continue listening for the end of the plan/task. There will still be an issue if the 'task complete' message is sent before the client can reconnect but this is a limitation of using a message bus.
The default time to wait before attempting to reconnect is 10s. For the client, this might benefit from being reduced, or changed to have a slow backoff (1s, 2s, 3s, 5s, 10s,... etc).
The server aborts a task if it can't send messages
When the server broadcasts events, if any of the callbacks fail, the exception is not sent to any other callbacks and the exception breaks the worker out of the task that it is running. This means if the server loses its connection the message bus, it aborts the task without sending the 'task complete' message meaning the client hangs indefinitely.
This is potentially fixed in fix: Handle errors from event stream callbacks #1302. Combined with the bluesky-stomp fix, the server will continue with the task it is running and when the message bus is available again it will continue sending events. If this is before the task is complete, this will allow the client to continue. Again, if the task completes before the message bus is available we'll be back in the infinite wait scenario again.
Activity
[-]run_task doesn't work, hangs until it times out, but also doesn't respect timeout[/-][+]run_task/blueapi cli client doesn't work, hangs until it times out, but also doesn't respect timeout[/+]RJCD-Diamond commentedon Oct 10, 2025
Another minimal example with plans not specific to SCM beamline
It was hanging on the second iteration on b21 at the time, but is not consistent
[-]run_task/blueapi cli client doesn't work, hangs until it times out, but also doesn't respect timeout[/-][+]run_task/blueapi hangs until it times out, but also doesn't respect timeout[/+]RJCD-Diamond commentedon Oct 14, 2025
It's possible this will be fixed by #1232
RJCD-Diamond commentedon Oct 28, 2025
#1232 has not fixed it
[-]run_task/blueapi hangs until it times out, but also doesn't respect timeout[/-][+]run_task/blueapi hangs until it times out[/+]abbiemery commentedon Nov 4, 2025
Can I ask what you are trying to do/why you are implementing this using
time.sleep? I don't know exactly what is happening without digging into it, but since this is a blocking call on that thread its a good candidate for shenanigans. If I know what you are trying to achieve we can do it in a way that works better with the eco-system.abbiemery commentedon Nov 4, 2025
It's hanging on the dodal wrapped versions of bps.set_absolute and set_relative at the moment.Putting your comment from slack here as notes.
RJCD-Diamond commentedon Nov 4, 2025
You get the same behaviour with from dodal.plan_stubs.wrapped import sleep - if that's what you're wondering.
The sleep is just there just to stop requests coming in too frequently, in case that was an issue.
I'm trying to give a blueapi scripting interface for the beamline scientist for commissioning purposes. If I can give them the building blocks of the system, then they should have everything they need to start using it in ernest
RJCD-Diamond commentedon Nov 4, 2025
Also when looking at the logs/messages of blueapi - the TaskRequest that it fails on is actually executed and is completed successfully without error
RJCD-Diamond commentedon Nov 4, 2025
The absolutely most minimal example
RJCD-Diamond commentedon Nov 6, 2025
Possibly related:
#1160
olliesilvester commentedon Nov 21, 2025
@RJCD-Diamond Do you have the logs for when this last happened? We saw another weird thing happen on i04 today, I'm wondering if it's all related
RJCD-Diamond commentedon Nov 28, 2025
No useful logs in graylog, however on the client side I get the following error:
and in the BlueAPI logs I get (which looks normal) but never proceeds to the next iterations of the loop:
RJCD-Diamond commentedon Nov 28, 2025
Also anecdotally it is a) worse during the day (died on about the 3 iter), compared to at night (5th iter) b) better during shutdown, c) better on a tuesday shutdown d) much better when the water leak happened (15th iter)
olliesilvester commentedon Nov 28, 2025
So yes, this is the same thing as we've seen a few times on i04. This is a high priority issue for MX too - until it's resolved it means we shouldn't really leave BlueAPI on a UDC beamline.
tpoliaw commentedon Dec 12, 2025
I've been digging into this and while I can't reproduce it from the example you have above, I did find a couple of related issues. I'm not sure if either is causing it on its own but it would be good to test with them fixed to check if they resolve this issue.
The closest I could get to reproducing the problem was by stopping activemq while a scan was running - mainly inspired by the
Stomp connection lostmessage you were getting in the client.The stomp client doesn't reliably reconnect
When the activemq service is restarted, the client never seems to reconnect to it meaning it never gets the 'task complete' message and waits indefinitely. This is potentially fixed by Catch and wrap unexpected connection errors bluesky-stomp#45 . With this patch included, the client can re-connect and continue listening for the end of the plan/task. There will still be an issue if the 'task complete' message is sent before the client can reconnect but this is a limitation of using a message bus.
The default time to wait before attempting to reconnect is 10s. For the client, this might benefit from being reduced, or changed to have a slow backoff (1s, 2s, 3s, 5s, 10s,... etc).
The server aborts a task if it can't send messages
When the server broadcasts events, if any of the callbacks fail, the exception is not sent to any other callbacks and the exception breaks the worker out of the task that it is running. This means if the server loses its connection the message bus, it aborts the task without sending the 'task complete' message meaning the client hangs indefinitely.
This is potentially fixed in fix: Handle errors from event stream callbacks #1302. Combined with the bluesky-stomp fix, the server will continue with the task it is running and when the message bus is available again it will continue sending events. If this is before the task is complete, this will allow the client to continue. Again, if the task completes before the message bus is available we'll be back in the infinite wait scenario again.
olliesilvester commentedon Jan 28, 2026
Thanks for looking into this Peter! I'll post again here if I see the issue again