Skip to content

Commit

Permalink
simpler, per @tacaswell
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jul 31, 2024
1 parent b67697f commit 9df37cd
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions ophyd/utils/epics_pvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,10 @@ def _wait_for_value(signal, val, poll_time=0.01, timeout=10, rtol=None, atol=Non
TimeoutError if timeout is exceeded
"""
expiration_time = ttime.time() + timeout if timeout is not None else None
is_array = isinstance(val, (list, np.ndarray, tuple))
if is_array:
current_value = signal.get(count=len(val))
else:
current_value = signal.get()
get_kwargs = {}
if isinstance(val, (list, np.ndarray, tuple)):
get_kwargs["count"] = len(val)
current_value = signal.get(**get_kwargs)

if atol is None and hasattr(signal, "tolerance"):
atol = signal.tolerance
Expand Down Expand Up @@ -309,10 +308,7 @@ def _wait_for_value(signal, val, poll_time=0.01, timeout=10, rtol=None, atol=Non
ttime.sleep(poll_time)
if poll_time < 0.1:
poll_time *= 2 # logarithmic back-off
if is_array:
current_value = signal.get(count=len(val))
else:
current_value = signal.get()
current_value = signal.get(**get_kwargs)
if expiration_time is not None and ttime.time() > expiration_time:
raise TimeoutError(
"Attempted to set %r to value %r and timed "
Expand Down

0 comments on commit 9df37cd

Please sign in to comment.