From 260fc33756a3d8187cbcb5f7d4e07ccf2a961791 Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Tue, 3 Dec 2024 11:36:50 +0100 Subject: [PATCH] raise as more generic ConnectionError, because ClientResponseError cannot be created easily --- mapchete/executor/future.py | 1 + mapchete/io/_misc.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mapchete/executor/future.py b/mapchete/executor/future.py index 351c82c3..dcea5734 100644 --- a/mapchete/executor/future.py +++ b/mapchete/executor/future.py @@ -123,6 +123,7 @@ def skip(skip_info: Optional[Any] = None, result: Optional[Any] = None) -> MFutu def from_func( func: Callable, fargs: Optional[Tuple] = None, fkwargs: Optional[Dict] = None ) -> MFuture: + fkwargs = fkwargs or {} try: return MFuture(result=func(*fargs, **fkwargs)) except Exception as exc: # pragma: no cover diff --git a/mapchete/io/_misc.py b/mapchete/io/_misc.py index c37822c5..44eba2f5 100644 --- a/mapchete/io/_misc.py +++ b/mapchete/io/_misc.py @@ -1,7 +1,6 @@ import logging from enum import Enum -from aiohttp import ClientResponseError import rasterio from rasterio.warp import calculate_default_transform from shapely.errors import TopologicalError @@ -216,5 +215,7 @@ def copy(src_path, dst_path, src_fs=None, dst_fs=None, overwrite=False): if repr(exception).startswith( 'Exception("ClientResponseError' ): # pragma: no cover - raise ClientResponseError(exception) from exception + raise ConnectionError(repr(exception)).with_traceback( + exception.__traceback__ + ) from exception raise