Skip to content

Commit

Permalink
Log and recover from occasional openslide failures
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Feb 2, 2024
1 parent 686025e commit 86d2f5c
Showing 1 changed file with 10 additions and 3 deletions.
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 @@ def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs):
self.tileHeight * svslevel['scale']))
break
except openslide.lowlevel.OpenSlideError as exc:
self._largeImagePath = str(self._getLargeImagePath())
msg = (
'Failed to get OpenSlide region '
f'({exc} on {self._largeImagePath}: {self}).')
self.logger.info(msg)
# Reopen handle after a lowlevel error
self._openslide = openslide.OpenSlide(self._largeImagePath)
try:
self._openslide = openslide.OpenSlide(self._largeImagePath)
except Exception:
raise TileSourceError(msg)
retries -= 1
if retries <= 0:
raise TileSourceError(
'Failed to get OpenSlide region (%r).' % exc)
raise TileSourceError(msg)
# Always scale to the svs level 0 tile size.
if svslevel['scale'] != 1:
tile = tile.resize((self.tileWidth, self.tileHeight),
Expand Down

0 comments on commit 86d2f5c

Please sign in to comment.