fix(flomni): close race between sample-storage EPICS writes and reads
CI for csaxs_bec / test (push) Failing after 6m18s

ftransfer_sample_change occasionally raised "The gripper does not carry
a sample" right after a successful get, even though the gripper
physically held one. Root cause: flomni_modify_storage_non_interactive
wrote the sample_in_gripper/sample_placed signals with EpicsSignal.set()
without waiting for the write to complete, and the immediately-following
is_sample_in_gripper()/is_sample_slot_used() checks read the
auto_monitor-cached value, which could still reflect the pre-write state.

Wait on each .set() call (5s timeout, matching the existing
.set(...).wait(timeout=...) pattern used elsewhere for EPICS writes),
and force is_sample_in_gripper()/is_sample_slot_used() to do a live
get(use_monitor=False) read instead of trusting the monitor cache
(mirroring the same pattern already used in ddg_1.py). This closes the
race deterministically instead of masking it with an arbitrary sleep.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XdHenMmwbrCz1juWMi1yZc
This commit is contained in:
x12saandClaude Sonnet 5 committed 2026-09-11 10:18:29 +02:00
1 parent 59cdc5c512
commit f56d11d730
2 files changed
+14 -14

No files matched your search

@@ -1048,13 +1048,13 @@ class FlomniSampleTransferMixin:
):
packed_name = pack_desc(name, owner)
if position == 100:
dev.flomni_samples.sample_in_gripper.set(used)
dev.flomni_samples.sample_in_gripper_name.set(packed_name)
dev.flomni_samples.sample_in_gripper.set(used).wait(timeout=5)
dev.flomni_samples.sample_in_gripper_name.set(packed_name).wait(timeout=5)
else:
signal = getattr(dev.flomni_samples.sample_placed, f"sample{position}")
signal.set(used)
signal.set(used).wait(timeout=5)
signal_name = getattr(dev.flomni_samples.sample_names, f"sample{position}")
signal_name.set(packed_name)
signal_name.set(packed_name).wait(timeout=5)
def check_position_is_valid(self, position: int):
if 0 <= position < 21:
+10 -10
View File
@@ -64,30 +64,30 @@ class FlomniSampleStorage(Device):
if slot_nr > 20:
raise FlomniSampleStorageError(f"Invalid slot number {slot_nr}.")
getattr(self.sample_placed, f"sample{slot_nr}").set(1)
getattr(self.sample_names, f"sample{slot_nr}").set(pack_desc(name, owner))
getattr(self.sample_placed, f"sample{slot_nr}").set(1).wait(timeout=5)
getattr(self.sample_names, f"sample{slot_nr}").set(pack_desc(name, owner)).wait(timeout=5)
def unset_sample_slot(self, slot_nr: int) -> bool:
if slot_nr > 20:
raise FlomniSampleStorageError(f"Invalid slot number {slot_nr}.")
getattr(self.sample_placed, f"sample{slot_nr}").set(0)
getattr(self.sample_names, f"sample{slot_nr}").set("-")
getattr(self.sample_placed, f"sample{slot_nr}").set(0).wait(timeout=5)
getattr(self.sample_names, f"sample{slot_nr}").set("-").wait(timeout=5)
def set_sample_in_gripper(self, name: str, owner: str = "") -> bool:
self.sample_in_gripper.set(1)
self.sample_in_gripper_name.set(pack_desc(name, owner))
self.sample_in_gripper.set(1).wait(timeout=5)
self.sample_in_gripper_name.set(pack_desc(name, owner)).wait(timeout=5)
def unset_sample_in_gripper(self) -> bool:
self.sample_in_gripper.set(0)
self.sample_in_gripper_name.set("-")
self.sample_in_gripper.set(0).wait(timeout=5)
self.sample_in_gripper_name.set("-").wait(timeout=5)
def is_sample_slot_used(self, slot_nr: int) -> bool:
val = getattr(self.sample_placed, f"sample{slot_nr}").get()
val = getattr(self.sample_placed, f"sample{slot_nr}").get(use_monitor=False)
return bool(val)
def is_sample_in_gripper(self) -> bool:
val = self.sample_in_gripper.get()
val = self.sample_in_gripper.get(use_monitor=False)
return bool(val)
def get_sample_name(self, slot_nr) -> str: