|
11 | 11 | import signal
|
12 | 12 | import subprocess
|
13 | 13 | import time
|
14 |
| - |
| 14 | +import traceback |
15 | 15 | import pprint
|
16 | 16 | import ast
|
17 | 17 |
|
@@ -1704,30 +1704,42 @@ def analysis_loop(self):
|
1704 | 1704 | # imported. So we'll silence them in this thread too:
|
1705 | 1705 | h5py._errors.silence_errors()
|
1706 | 1706 | 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') |
1721 | 1728 | 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() |
1731 | 1743 |
|
1732 | 1744 |
|
1733 | 1745 | @inmain_decorator()
|
|
0 commit comments