Commit 12d30daa authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Moved rasterio imports to function level to avoid static TLS conflict with...

Moved rasterio imports to function level to avoid static TLS conflict with pykdtree which is a dependency of pyresample.
parent fa0b0006
Pipeline #3737 passed with stages
in 1 minute and 29 seconds
......@@ -14,10 +14,9 @@ except ImportError:
import gdal
import gdalnumeric
import rasterio
from rasterio.warp import reproject as rio_reproject
from rasterio.warp import calculate_default_transform as rio_calc_transform
from rasterio.warp import Resampling
# NOTE: In case of ImportError: dlopen: cannot load any more object with static TLS,
# one could add 'from pykdtree.kdtree import KDTree' here (before pyresample import)
from pyresample.geometry import AreaDefinition, SwathDefinition
from pyresample.utils import get_area_def
from pyresample.bilinear import resample_bilinear
......@@ -63,6 +62,16 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
:return out_gt: warped gdal GeoTransform
:return out_prj: warped projection as WKT string
"""
# NOTE: rasterio seems to increase the number of objects with static TLS
# There is a maximum number and if this is exceeded an ImportError is raised:
# ImportError: dlopen: cannot load any more object with static TLS
# - see also: https://gitext.gfz-potsdam.de/danschef/py_tools_ds/issues/8
# - NOTE: importing rasterio AFTER pyresample (which uses pykdtree) seems to solve that too
# => keep the rasterio import within the function locals to avoid not needed imports
import rasterio
from rasterio.warp import reproject as rio_reproject
from rasterio.warp import calculate_default_transform as rio_calc_transform
from rasterio.warp import Resampling
if not ndarray.flags['OWNDATA']:
temp = np.empty_like(ndarray)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment