Skip to content

Commit c2d9fb3

Browse files
Merged in cbillington/lyse/bugfix3 (pull request labscript-suite#33)
Fixes issue labscript-suite#27: lyse broken after analysis loop crash Approved-by: Jan Werkmann <jan.wrk.fb@gmail.com>
2 parents 35fc579 + 3a94955 commit c2d9fb3

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

__main__.py

+36-24
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import signal
1212
import subprocess
1313
import time
14-
14+
import traceback
1515
import pprint
1616
import ast
1717

@@ -1704,30 +1704,42 @@ def analysis_loop(self):
17041704
# imported. So we'll silence them in this thread too:
17051705
h5py._errors.silence_errors()
17061706
while True:
1707-
self.analysis_pending.wait()
1708-
self.analysis_pending.clear()
1709-
at_least_one_shot_analysed = False
1710-
while True:
1711-
if not self.analysis_paused:
1712-
# Find the first shot that has not finished being analysed:
1713-
filepath = self.shots_model.get_first_incomplete()
1714-
if filepath is not None:
1715-
logger.info('analysing: %s'%filepath)
1716-
self.do_singleshot_analysis(filepath)
1717-
at_least_one_shot_analysed = True
1718-
if filepath is None and at_least_one_shot_analysed:
1719-
self.multishot_required = True
1720-
if filepath is None:
1707+
try:
1708+
self.analysis_pending.wait()
1709+
self.analysis_pending.clear()
1710+
at_least_one_shot_analysed = False
1711+
while True:
1712+
if not self.analysis_paused:
1713+
# Find the first shot that has not finished being analysed:
1714+
filepath = self.shots_model.get_first_incomplete()
1715+
if filepath is not None:
1716+
logger.info('analysing: %s'%filepath)
1717+
self.do_singleshot_analysis(filepath)
1718+
at_least_one_shot_analysed = True
1719+
if filepath is None and at_least_one_shot_analysed:
1720+
self.multishot_required = True
1721+
if filepath is None:
1722+
break
1723+
if self.multishot_required:
1724+
logger.info('doing multishot analysis')
1725+
self.do_multishot_analysis()
1726+
else:
1727+
logger.info('analysis is paused')
17211728
break
1722-
if self.multishot_required:
1723-
logger.info('doing multishot analysis')
1724-
self.do_multishot_analysis()
1725-
else:
1726-
logger.info('analysis is paused')
1727-
break
1728-
if self.multishot_required:
1729-
logger.info('doing multishot analysis')
1730-
self.do_multishot_analysis()
1729+
if self.multishot_required:
1730+
logger.info('doing multishot analysis')
1731+
self.do_multishot_analysis()
1732+
except Exception:
1733+
etype, value, tb = sys.exc_info()
1734+
orig_exception = ''.join(traceback.format_exception_only(etype, value))
1735+
message = ('Analysis loop encountered unexpected exception. ' +
1736+
'This is a bug and should be reported. The analysis ' +
1737+
'loop is continuing, but lyse may be in an inconsistent state. '
1738+
'Restart lyse, or continue at your own risk. '
1739+
'Original exception was:\n\n' + orig_exception)
1740+
# Raise the exception in a thread so we can keep running
1741+
zprocess.raise_exception_in_thread((RuntimeError, RuntimeError(message), tb))
1742+
self.pause_analysis()
17311743

17321744

17331745
@inmain_decorator()

0 commit comments

Comments
 (0)