This commit is contained in:
2025-09-03 10:38:50 +02:00
parent 4f889e2b97
commit 0b9961cf18
2 changed files with 23 additions and 21 deletions

View File

@@ -63,13 +63,14 @@ class AndStatus(StatusBase):
with self._lock:
if self._externally_initiated_completion:
return
if self.done: # Return if status is already done.. It must be resolved already
return
for st in self.all_statuses:
with st._lock:
if not self.done:
if st.done and not st.success:
self.set_exception(st.exception())
return
if st.done and not st.success:
self.set_exception(st.exception())
return
if all(st.done for st in self.all_statuses) and all(
st.success for st in self.all_statuses

View File

@@ -261,24 +261,25 @@ class TimepixFlyClient:
callback_ids = list(self._status_callbacks.keys())
for cb_id in callback_ids:
dev_status, success, error = self._status_callbacks[cb_id]
if dev_status.done:
self._status_callbacks.pop(cb_id)
continue
if status in success:
dev_status.set_finished()
logger.info(f"Status callback finished in succes: {status.value}")
self._status_callbacks.pop(cb_id)
elif status in error:
last_error = self.last_error()
logger.error(
f"Timepix status in error is {status.value}, with last error: {last_error.message}"
)
dev_status.set_exception(
TimePixStatusError(
f"TimePixStatus status is '{status.value},' last error message: {last_error.message}"
with dev_status._lock:
if dev_status.done:
self._status_callbacks.pop(cb_id)
continue
if status in success:
dev_status.set_finished()
logger.info(f"Status callback finished in succes: {status.value}")
self._status_callbacks.pop(cb_id)
elif status in error:
last_error = self.last_error()
logger.error(
f"Timepix status in error is {status.value}, with last error: {last_error.message}"
)
)
self._status_callbacks.pop(cb_id)
dev_status.set_exception(
TimePixStatusError(
f"TimePixStatus status is '{status.value},' last error message: {last_error.message}"
)
)
self._status_callbacks.pop(cb_id)
# Reset the _started flag if the status is in CONFIG.
if status == TimePixFlyStatus.CONFIG:
self._started = False # Should this be made thread-safe?