Skip to content

Commit

Permalink
fix: Do not return early
Browse files Browse the repository at this point in the history
According to this principle from Alej "once is never, twice is always."
See pr comments.
  • Loading branch information
giulioungaretti committed Mar 2, 2017
1 parent 2cfc574 commit 24508f2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions qcodes/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ def run(self, background=USE_MP, use_threads=False, quiet=False,
# this one later.
self.data_set = None


return ds

def _compile_actions(self, actions, action_indices=()):
Expand Down Expand Up @@ -943,6 +942,9 @@ def _run_loop(self, first_delay=0, action_indices=(),
t0 = time.time()
last_task = t0
imax = len(self.sweep_values)

self.last_task_failed = False

for i, value in enumerate(self.sweep_values):
if self.progress_interval is not None:
tprint('loop %s: %d/%d (%.1f [s])' % (
Expand Down Expand Up @@ -1000,14 +1002,17 @@ def _run_loop(self, first_delay=0, action_indices=(),
try:
self.bg_task()
except Exception:
if self.last_task_failed:
self.bg_task = None
self.last_task_failed = True
log.exception("Failed to execute bg task")
self.bg_task = None
return

last_task = t

if self.progress_interval is not None:
# final progress note: set dt=-1 so it *always* prints
tprint('loop %s DONE: %d/%d (%.1f [s])' % (

self.sweep_values.name, i + 1, imax, time.time() - t0),
dt=-1, tag='outerloop')

Expand All @@ -1023,7 +1028,6 @@ def _run_loop(self, first_delay=0, action_indices=(),
if self.bg_final_task is not None:
self.bg_final_task()


def _wait(self, delay):
if delay:
finish_clock = time.perf_counter() + delay
Expand Down

0 comments on commit 24508f2

Please sign in to comment.