diff --git a/CHANGELOG.md b/CHANGELOG.md index 03ad30258..1acd87e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Changes - Update WsiDicomWebClient init call ([#1371](../../pull/1371)) - Rename DICOMweb AssetstoreImportView ([#1372](../../pull/1372)) +- Harden bioformats shutdown ([#1375](../../pull/1375)) ### Bug Fixes - Default to "None" for the DICOM assetstore limit ([#1359](../../pull/1359)) diff --git a/sources/bioformats/large_image_source_bioformats/__init__.py b/sources/bioformats/large_image_source_bioformats/__init__.py index 2e61e9426..477888bde 100644 --- a/sources/bioformats/large_image_source_bioformats/__init__.py +++ b/sources/bioformats/large_image_source_bioformats/__init__.py @@ -74,7 +74,10 @@ def _monitor_thread(): source._bioimage.close() except Exception: pass - source._bioimage = None + try: + source._bioimage = None + except Exception: + pass except AssertionError: pass finally: @@ -128,8 +131,8 @@ def _startJavabridge(logger): atexit.register(_stopJavabridge) logger.info('Started JVM for Bioformats tile source.') _javabridgeStarted = True - except RuntimeError as exc: - logger.exception('Cannot start JVM for Bioformats tile source.', exc) + except RuntimeError: + logger.exception('Cannot start JVM for Bioformats tile source.') _javabridgeStarted = False return _javabridgeStarted @@ -178,7 +181,7 @@ def __init__(self, path, **kwargs): # noqa super().__init__(path, **kwargs) largeImagePath = str(self._getLargeImagePath()) - self._ignoreSourceNames('bioformats', largeImagePath, r'\.png$') + self._ignoreSourceNames('bioformats', largeImagePath, r'(^[^.]*|\.(png|zarr(\.db|\.zip)))$') if not _startJavabridge(self.logger): msg = 'File cannot be opened by bioformats reader because javabridge failed to start' @@ -276,6 +279,8 @@ def __del__(self): self._bioimage.close() del self._bioimage _openImages.remove(weakref.ref(self)) + except Exception: + pass finally: if javabridge.get_env(): javabridge.detach()