Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Log exception and exit #505

Merged
merged 2 commits into from
Mar 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions qcodes/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"""

from datetime import datetime
import logging
import multiprocessing as mp
import time
import numpy as np
Expand All @@ -64,6 +65,8 @@
from .actions import (_actions_snapshot, Task, Wait, _Measure, _Nest,
BreakIf, _QcodesBreak)


log = logging.getLogger(__name__)
# Switches off multiprocessing by default, cant' be altered after module
USE_MP = config.core.legacy_mp
MP_NAME = 'Measurement'
Expand Down Expand Up @@ -870,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 @@ -939,8 +941,10 @@ def _run_loop(self, first_delay=0, action_indices=(),

t0 = time.time()
last_task = t0
last_task_failed = False
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 @@ -997,16 +1001,18 @@ def _run_loop(self, first_delay=0, action_indices=(),
if t - last_task >= self.bg_min_delay:
try:
self.bg_task()
last_task_failed = False
except Exception:
if last_task_failed:
if self.last_task_failed:
self.bg_task = None
last_task_failed = True
self.last_task_failed = True
log.exception("Failed to execute bg task")

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 @@ -1022,8 +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