Skip to content

Commit

Permalink
Merge pull request #1375 from girder/harden-bioformats
Browse files Browse the repository at this point in the history
Harden bioformats shutdown.
  • Loading branch information
manthey authored Nov 16, 2023
2 parents 32b8d01 + 5cee28a commit 329226e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
13 changes: 9 additions & 4 deletions sources/bioformats/large_image_source_bioformats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 329226e

Please sign in to comment.