Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden bioformats shutdown. #1375

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
source._bioimage.close()
except Exception:
pass
source._bioimage = None
try:
source._bioimage = None
except Exception:
pass

Check warning on line 80 in sources/bioformats/large_image_source_bioformats/__init__.py

View check run for this annotation

Codecov / codecov/patch

sources/bioformats/large_image_source_bioformats/__init__.py#L77-L80

Added lines #L77 - L80 were not covered by tests
except AssertionError:
pass
finally:
Expand Down Expand Up @@ -128,8 +131,8 @@
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 @@
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 @@
self._bioimage.close()
del self._bioimage
_openImages.remove(weakref.ref(self))
except Exception:
pass

Check warning on line 283 in sources/bioformats/large_image_source_bioformats/__init__.py

View check run for this annotation

Codecov / codecov/patch

sources/bioformats/large_image_source_bioformats/__init__.py#L282-L283

Added lines #L282 - L283 were not covered by tests
finally:
if javabridge.get_env():
javabridge.detach()
Expand Down