From 20db92c1084b9d115f5c863c65faf0fdefb19149 Mon Sep 17 00:00:00 2001 From: Moritz Kirmse Date: Tue, 20 Jul 2021 15:54:13 +0200 Subject: [PATCH] reduce scope of try ... except block --- mapproxy/cache/tile.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mapproxy/cache/tile.py b/mapproxy/cache/tile.py index 515eff559..9e8f5df84 100644 --- a/mapproxy/cache/tile.py +++ b/mapproxy/cache/tile.py @@ -378,22 +378,22 @@ def _create_single_tile(self, tile): if not self.is_cached(tile): try: source = self._query_sources(query) - if not source: return [] - if self.tile_mgr.image_opts != source.image_opts: - # call as_buffer to force conversion into cache format - source.as_buffer(self.tile_mgr.image_opts) - source.image_opts = self.tile_mgr.image_opts - tile.source = source - tile.cacheable = source.cacheable - tile = self.tile_mgr.apply_tile_filter(tile) - if source.cacheable: - self.cache.store_tile(tile) # if source is not available, try to serve tile in cache except SourceError as e: if self.is_stale(tile): self.cache.load_tile(tile) else: reraise_exception(e, sys.exc_info()) + if not source: return [] + if self.tile_mgr.image_opts != source.image_opts: + # call as_buffer to force conversion into cache format + source.as_buffer(self.tile_mgr.image_opts) + source.image_opts = self.tile_mgr.image_opts + tile.source = source + tile.cacheable = source.cacheable + tile = self.tile_mgr.apply_tile_filter(tile) + if source.cacheable: + self.cache.store_tile(tile) else: self.cache.load_tile(tile) return [tile]