33# deepzoom_multiserver - Example web application for viewing multiple slides
44#
55# Copyright (c) 2010-2015 Carnegie Mellon University
6- # Copyright (c) 2021 Benjamin Gilbert
6+ # Copyright (c) 2021-2022 Benjamin Gilbert
77#
88# This library is free software; you can redistribute it and/or modify it
99# under the terms of version 2.1 of the GNU Lesser General Public License
4444else :
4545 import openslide
4646
47- from openslide import OpenSlide , OpenSlideCache , OpenSlideError
47+ from openslide import OpenSlide , OpenSlideCache , OpenSlideError , OpenSlideVersionError
4848from openslide .deepzoom import DeepZoomGenerator
4949
5050SLIDE_DIR = '.'
@@ -67,8 +67,11 @@ def __init__(self, cache_size, tile_cache_mb, dz_opts):
6767 self .dz_opts = dz_opts
6868 self ._lock = Lock ()
6969 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
7275
7376 def get (self , path ):
7477 with self ._lock :
@@ -79,7 +82,8 @@ def get(self, path):
7982 return slide
8083
8184 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 )
8387 slide = DeepZoomGenerator (osr , ** self .dz_opts )
8488 try :
8589 mpp_x = osr .properties [openslide .PROPERTY_NAME_MPP_X ]
0 commit comments