From c0faeb6f6bf5e4362e6de83fb82952271d3d9a65 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 18 Dec 2023 08:09:53 -0500 Subject: [PATCH] Don't automatically flush memcached tile cache on exit --- CHANGELOG.md | 1 + large_image/cache_util/__init__.py | 13 ++++++++++--- large_image/tilesource/base.py | 1 - 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 854db6445..a98f686f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ### Changes - Use an enum for priority constants ([#1400](../../pull/1400)) +- Don't automatically flush memcached tile cache on exit ([#1409](../../pull/1409)) ### Bug Fixes - Fix an issue emitting geojson annotations ([#1395](../../pull/1395)) diff --git a/large_image/cache_util/__init__.py b/large_image/cache_util/__init__.py index 4d1692c79..bbbe22e70 100644 --- a/large_image/cache_util/__init__.py +++ b/large_image/cache_util/__init__.py @@ -30,7 +30,7 @@ @atexit.register -def cachesClear(*args, **kwargs): +def cachesClearExceptTile(*args, **kwargs): """ Clear the tilesource caches and the load model cache. Note that this does not clear memcached (which could be done with tileCache._client.flush_all, @@ -39,6 +39,15 @@ def cachesClear(*args, **kwargs): for name in LruCacheMetaclass.namedCaches: with LruCacheMetaclass.namedCaches[name][1]: LruCacheMetaclass.namedCaches[name][0].clear() + for func in _cacheClearFuncs: + func() + + +def cachesClear(*args, **kwargs): + """ + Clear the tilesource caches, the load model cache, and the tile cache. + """ + cachesClearExceptTile() if isTileCacheSetup(): tileCache, tileLock = getTileCache() try: @@ -46,8 +55,6 @@ def cachesClear(*args, **kwargs): tileCache.clear() except Exception: pass - for func in _cacheClearFuncs: - func() def cachesInfo(*args, **kwargs): diff --git a/large_image/tilesource/base.py b/large_image/tilesource/base.py index 334ddd63a..f29e36f34 100644 --- a/large_image/tilesource/base.py +++ b/large_image/tilesource/base.py @@ -1583,7 +1583,6 @@ def _outputTileNumpyStyle(self, tile, applyStyle, x, y, z, frame=None): :returns: a numpy array and a target PIL image mode. """ tile, mode = _imageToNumpy(tile) - # if applyStyle and (getattr(self, 'style', None) or hasattr(self, '_iccprofiles')): if (applyStyle and (getattr(self, 'style', None) or hasattr(self, '_iccprofiles')) and (not getattr(self, 'style', None) or len(self.style) != 1 or self.style.get('icc') is not False)):