Merge branch 'stitching-cancel' into 'v3'
Adjust catching of InvocationCancelledError so stiching reports as cancelled See merge request openflexure/openflexure-microscope-server!637
This commit is contained in:
commit
d7421ccea5
1 changed files with 10 additions and 7 deletions
|
|
@ -313,17 +313,19 @@ class SmartScanThing(OFMThing):
|
||||||
# If _scan_data is set then scan started
|
# If _scan_data is set then scan started
|
||||||
if self._scan_data is not None:
|
if self._scan_data is not None:
|
||||||
self._return_to_starting_position()
|
self._return_to_starting_position()
|
||||||
if not isinstance(e, scan_directories.NotEnoughFreeSpaceError):
|
|
||||||
# Don't stitch if drive is full (already logged)
|
|
||||||
self.logger.info(
|
|
||||||
"Attempting to stitch and archive the images acquired so far."
|
|
||||||
)
|
|
||||||
self._perform_final_stitch()
|
|
||||||
if self._ongoing_scan is not None:
|
if self._ongoing_scan is not None:
|
||||||
# Save any final messages even if there is an exception.
|
# Save any final messages even if there is an exception.
|
||||||
self._ongoing_scan.save_scan_log(self)
|
self._ongoing_scan.save_scan_log(self)
|
||||||
# Error must be raised so UI gives correct output
|
# Error must be raised so UI gives correct output
|
||||||
raise e
|
raise e
|
||||||
|
except lt.exceptions.InvocationCancelledError as e:
|
||||||
|
# InvocationCancelledError is caught in `_run_scan` if it happens
|
||||||
|
# while scanning, but it propagates if it occurs during stitching.
|
||||||
|
# If raised we still need to save the scan log.
|
||||||
|
if self._ongoing_scan is not None:
|
||||||
|
self._ongoing_scan.save_scan_log(self)
|
||||||
|
# Reraise so the action reports as cancelled if stitching is cancelled.
|
||||||
|
raise e
|
||||||
finally:
|
finally:
|
||||||
# However the scan finishes, unset all variables and release lock
|
# However the scan finishes, unset all variables and release lock
|
||||||
self._ongoing_scan = None
|
self._ongoing_scan = None
|
||||||
|
|
@ -728,9 +730,10 @@ class SmartScanThing(OFMThing):
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
final_stitcher.run()
|
final_stitcher.run()
|
||||||
except lt.exceptions.InvocationCancelledError:
|
except lt.exceptions.InvocationCancelledError as e:
|
||||||
# Sleep for 1 second just to allow invocation logs to pass to user.
|
# Sleep for 1 second just to allow invocation logs to pass to user.
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
raise e
|
||||||
except ChildProcessError as e:
|
except ChildProcessError as e:
|
||||||
self.logger.error(f"Stitching failed: {e}", exc_info=e)
|
self.logger.error(f"Stitching failed: {e}", exc_info=e)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue