Exception: dlopen: cannot load any more object with static TLS
It seems like there is a maximum number of objects with static TLS. In case py_tools_ds.geo.raster.reproject is imported from sicor, this number is exceeded. This causes the following exception during import of sicor:
Traceback (most recent call last):
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
yield
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/unittest/case.py", line 615, in run
testMethod()
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/imp.py", line 171, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/gfz-fe/scheffler/python/EnPT/tests/test_controller.py", line 14, in <module>
from enpt.execution.controller import EnPT_Controller
File "/home/gfz-fe/scheffler/python/EnPT/enpt/execution/controller.py", line 14, in <module>
from ..options.config import EnPTConfig
File "/home/gfz-fe/scheffler/python/EnPT/enpt/options/config.py", line 20, in <module>
import sicor
File "/home/gfz-fe/scheffler/python_deployed/sicor/sicor/__init__.py", line 6, in <module>
from .sicor_ac import ac
File "/home/gfz-fe/scheffler/python_deployed/sicor/sicor/sicor_ac.py", line 46, in <module>
from .sensors.S2MSI import S2Image, GranuleDEM
File "/home/gfz-fe/scheffler/python_deployed/sicor/sicor/sensors/S2MSI/__init__.py", line 3, in <module>
from .S2Image import S2Image
File "/home/gfz-fe/scheffler/python_deployed/sicor/sicor/sensors/S2MSI/S2Image/__init__.py", line 1, in <module>
from .S2Image import S2Image
File "/home/gfz-fe/scheffler/python_deployed/sicor/sicor/sensors/S2MSI/S2Image/S2Image.py", line 25, in <module>
from geoarray import GeoArray
File "/home/gfz-fe/scheffler/python_deployed/geoarray/geoarray/__init__.py", line 7, in <module>
from .baseclasses import GeoArray # noqa: E402
File "/home/gfz-fe/scheffler/python_deployed/geoarray/geoarray/baseclasses.py", line 28, in <module>
from py_tools_ds.geo.coord_calc import get_corner_coordinates
File "/home/gfz-fe/scheffler/python_deployed/py_tools_ds/py_tools_ds/geo/__init__.py", line 1, in <module>
from . import raster
File "/home/gfz-fe/scheffler/python_deployed/py_tools_ds/py_tools_ds/geo/raster/__init__.py", line 5, in <module>
from . import reproject
File "/home/gfz-fe/scheffler/python_deployed/py_tools_ds/py_tools_ds/geo/raster/reproject.py", line 23, in <module>
from pyresample.bilinear import resample_bilinear
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/pyresample/__init__.py", line 27, in <module>
from pyresample import image # noqa
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/pyresample/image.py", line 24, in <module>
from pyresample import geometry, grid, kd_tree, bilinear
File "/home/gfz-fe/pygfz/envs/enpt/lib/python3.7/site-packages/pyresample/kd_tree.py", line 29, in <module>
from pykdtree.kdtree import KDTree
Exception: dlopen: cannot load any more object with static TLS
So far, I investigated pyresample and rasterio as libs related to that (with static TLS?).
Possible solutions:
- put a
from pykdtree.kdtree import KDTree
before the imports of pyresample and rasterio - import pyresample BEFORE rasterio
- move rasterio imports to function locals to avoid rasterio import if it is not needed