3
3
# deepzoom_multiserver - Example web application for viewing multiple slides
4
4
#
5
5
# Copyright (c) 2010-2015 Carnegie Mellon University
6
- # Copyright (c) 2021 Benjamin Gilbert
6
+ # Copyright (c) 2021-2022 Benjamin Gilbert
7
7
#
8
8
# This library is free software; you can redistribute it and/or modify it
9
9
# under the terms of version 2.1 of the GNU Lesser General Public License
44
44
else :
45
45
import openslide
46
46
47
- from openslide import OpenSlide , OpenSlideCache , OpenSlideError
47
+ from openslide import OpenSlide , OpenSlideCache , OpenSlideError , OpenSlideVersionError
48
48
from openslide .deepzoom import DeepZoomGenerator
49
49
50
50
SLIDE_DIR = '.'
@@ -67,8 +67,11 @@ def __init__(self, cache_size, tile_cache_mb, dz_opts):
67
67
self .dz_opts = dz_opts
68
68
self ._lock = Lock ()
69
69
self ._cache = OrderedDict ()
70
- # Share a single tile cache among all slide handles
71
- self ._tile_cache = OpenSlideCache (tile_cache_mb * 1024 * 1024 )
70
+ # Share a single tile cache among all slide handles, if supported
71
+ try :
72
+ self ._tile_cache = OpenSlideCache (tile_cache_mb * 1024 * 1024 )
73
+ except OpenSlideVersionError :
74
+ self ._tile_cache = None
72
75
73
76
def get (self , path ):
74
77
with self ._lock :
@@ -79,7 +82,8 @@ def get(self, path):
79
82
return slide
80
83
81
84
osr = OpenSlide (path )
82
- osr .set_cache (self ._tile_cache )
85
+ if self ._tile_cache is not None :
86
+ osr .set_cache (self ._tile_cache )
83
87
slide = DeepZoomGenerator (osr , ** self .dz_opts )
84
88
try :
85
89
mpp_x = osr .properties [openslide .PROPERTY_NAME_MPP_X ]
0 commit comments