Skip to content

Commit

Permalink
Added an explicit set_many() check that the exception is related.
Browse files Browse the repository at this point in the history
In ``set_many()`` we catch a TypeError to see if the *settle_time*
parameter is accepted by each signal's ``set()`` method, and if it is
we try again without the *settle_time* argument. If a TypeError is
raised for another reason, this would also retry the ``set()``
call. We can't guarantee that this is indempotent. Now we explicity
check that the TypeError is at least related to the *settle_time*
argument before retrying.
  • Loading branch information
canismarko committed May 25, 2024
1 parent 7da6723 commit 9efb2e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pcdsdevices/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,12 @@ def set_many(
try:
try:
st = signal.set(value, timeout=timeout, settle_time=settle_time)
except TypeError:
# It's probably a Positioner, which doesn't accept *settle_time*
st = signal.set(value, timeout=timeout)
except TypeError as exc:
if "settle_time" in str(exc):
# It's probably a Positioner, which doesn't accept *settle_time*
st = signal.set(value, timeout=timeout)
else:
raise
except Exception:
log.exception("Failed to set %s to %s", signal.name, value)
if raise_on_set_failure:
Expand Down

0 comments on commit 9efb2e6

Please sign in to comment.