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

Log and recover from occasional openslide failures #1461

Merged
merged 1 commit into from
Feb 2, 2024
Merged
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
13 changes: 10 additions & 3 deletions sources/openslide/large_image_source_openslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,19 @@
self.tileHeight * svslevel['scale']))
break
except openslide.lowlevel.OpenSlideError as exc:
self._largeImagePath = str(self._getLargeImagePath())
msg = (

Check warning on line 310 in sources/openslide/large_image_source_openslide/__init__.py

View check run for this annotation

Codecov / codecov/patch

sources/openslide/large_image_source_openslide/__init__.py#L309-L310

Added lines #L309 - L310 were not covered by tests
'Failed to get OpenSlide region '
f'({exc} on {self._largeImagePath}: {self}).')
self.logger.info(msg)

Check warning on line 313 in sources/openslide/large_image_source_openslide/__init__.py

View check run for this annotation

Codecov / codecov/patch

sources/openslide/large_image_source_openslide/__init__.py#L313

Added line #L313 was not covered by tests
# Reopen handle after a lowlevel error
self._openslide = openslide.OpenSlide(self._largeImagePath)
try:
self._openslide = openslide.OpenSlide(self._largeImagePath)
except Exception:
raise TileSourceError(msg)

Check warning on line 318 in sources/openslide/large_image_source_openslide/__init__.py

View check run for this annotation

Codecov / codecov/patch

sources/openslide/large_image_source_openslide/__init__.py#L315-L318

Added lines #L315 - L318 were not covered by tests
retries -= 1
if retries <= 0:
raise TileSourceError(
'Failed to get OpenSlide region (%r).' % exc)
raise TileSourceError(msg)

Check warning on line 321 in sources/openslide/large_image_source_openslide/__init__.py

View check run for this annotation

Codecov / codecov/patch

sources/openslide/large_image_source_openslide/__init__.py#L321

Added line #L321 was not covered by tests
# Always scale to the svs level 0 tile size.
if svslevel['scale'] != 1:
tile = tile.resize((self.tileWidth, self.tileHeight),
Expand Down