Skip to content

Commit

Permalink
Merge pull request #913 from girder/avoid-entrypoint-warning
Browse files Browse the repository at this point in the history
Avoid some warnings in Python 3.10.
  • Loading branch information
manthey authored Aug 5, 2022
2 parents 0a21266 + a2409d7 commit 300898b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion large_image/cache_util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def wrapper(self, *args, **kwargs):
self.cache[k] = v
except ValueError:
pass # value too large
except KeyError:
except (KeyError, RuntimeError):
# the key was refused for some reason
config.getConfig('logger').debug(
'Had a cache KeyError while trying to store a value to key %r' % (k))
Expand Down
22 changes: 12 additions & 10 deletions large_image/cache_util/cachefactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ def loadCaches(entryPointName='large_image.cache', sourceDict=_availableCaches):
if len(_availableCaches):
return
epoints = entry_points()
if entryPointName in epoints:
for entryPoint in epoints[entryPointName]:
try:
cacheClass = entryPoint.load()
sourceDict[entryPoint.name.lower()] = cacheClass
config.getConfig('logprint').debug(f'Loaded cache {entryPoint.name}')
except Exception:
config.getConfig('logprint').exception(
f'Failed to load cache {entryPoint.name}'
)
# Python 3.10 uses select and deprecates dictionary interface
epointList = epoints.select(group=entryPointName) if hasattr(
epoints, 'select') else epoints.get(entryPointName, [])
for entryPoint in epointList:
try:
cacheClass = entryPoint.load()
sourceDict[entryPoint.name.lower()] = cacheClass
config.getConfig('logprint').debug(f'Loaded cache {entryPoint.name}')
except Exception:
config.getConfig('logprint').exception(
f'Failed to load cache {entryPoint.name}'
)
# Load memcached last for now
if MemCache is not None:
# TODO: put this in an entry point for a new package
Expand Down
6 changes: 5 additions & 1 deletion large_image/tilesource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def loadTileSources(entryPointName='large_image.source', sourceDict=AvailableTil
:param entryPointName: the name of the entry points to load.
:param sourceDict: a dictionary to populate with the loaded sources.
"""
for entryPoint in entry_points()[entryPointName]:
epoints = entry_points()
# Python 3.10 uses select and deprecates dictionary interface
epointList = epoints.select(group=entryPointName) if hasattr(
epoints, 'select') else epoints.get(entryPointName, [])
for entryPoint in epointList:
try:
sourceClass = entryPoint.load()
if sourceClass.name and None in sourceClass.extensions:
Expand Down

0 comments on commit 300898b

Please sign in to comment.