Skip to content
Snippets Groups Projects
Verified Commit 38d6a968 authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Fix automatic delay detection

parent 5a3d0240
Branches
Tags
1 merge request!66Extend simulator module
Pipeline #1639842 waiting for manual action
......@@ -59,12 +59,12 @@ def with_delay(meth):
@wraps(meth)
def wrapped(self, *, delay=True, **settings):
skip_wait = getattr(wrapped, '__with_delay', False)
skip_delay = settings.pop('_skip_delay', False)
if delay is True:
delay = settings['n_pts'] / settings['fs']
it = meth(self, **settings)
it = meth(self, _skip_delay=True, **settings)
while True:
tic = time.perf_counter()
try:
......@@ -72,8 +72,8 @@ def with_delay(meth):
except StopIteration as stop:
return stop.value
else:
if delay and not skip_wait:
time.sleep(delay - (time.perf_counter() - tic))
if delay and not skip_delay:
time.sleep(max(0, delay - (time.perf_counter() - tic)))
yield data
......@@ -91,7 +91,6 @@ def with_delay(meth):
parameters = parameters + [delay_param]
wrapped.__signature__ = wrapped_sig.replace(parameters=parameters)
wrapped.__with_delay = True
return wrapped
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment