diff --git a/examples/call_async_cython.py b/examples/call_async_cython.py index 8d3810537..a4164472c 100755 --- a/examples/call_async_cython.py +++ b/examples/call_async_cython.py @@ -3,7 +3,7 @@ with a cythonized function located in function.so Commands to compile the function.py into function.so: -cython3 --embed -o function.c function.py +cython3 -3 --embed -X always_allow_keywords=true -o function.c function.py gcc -shared -o function.so -fPIC -I /usr/include/python3.9 function.c """ import lithops diff --git a/examples/function.py b/examples/function.py old mode 100755 new mode 100644 index 2f3737afa..25e83d4c1 --- a/examples/function.py +++ b/examples/function.py @@ -2,7 +2,7 @@ This function is used in call_async_cython.py Commands to compile the function.py into function.so: -cython3 --embed -o function.c function.py +cython3 -3 --embed -X always_allow_keywords=true -o function.c function.py gcc -shared -o function.so -fPIC -I /usr/include/python3.9 function.c """ def my_c_function(x): diff --git a/examples/function.so b/examples/function.so index 93492108b..bdd1841df 100755 Binary files a/examples/function.so and b/examples/function.so differ diff --git a/lithops/job/serialize.py b/lithops/job/serialize.py index a800ad456..21f2de99b 100644 --- a/lithops/job/serialize.py +++ b/lithops/job/serialize.py @@ -65,20 +65,20 @@ def __call__(self, list_of_objs, include_modules, exclude_modules): continue try: mod_spec = importlib.util.find_spec(module_name) - origin = mod_spec.origin if mod_spec else None - if origin and origin.endswith('.so'): - if origin not in exclude_modules and \ - os.path.basename(origin) not in exclude_modules: - mod_paths.add(origin) - else: - self._modulemgr.add(module_name) - direct_modules.add(origin if origin not in ['built-in', None] else module_name) except Exception: - direct_modules.add(module_name) + mod_spec = None + + origin = mod_spec.origin if mod_spec else module_name + if origin and origin.endswith('.so'): + if origin not in exclude_modules and \ + os.path.basename(origin) not in exclude_modules: + mod_paths.add(origin) + else: self._modulemgr.add(module_name) + direct_modules.add(origin if origin not in ['built-in', None] else module_name) - logger.debug("Referenced modules: {}".format(None if not direct_modules - else ", ".join(direct_modules))) + logger.debug("Referenced modules: {}".format(None if not + direct_modules else ", ".join(direct_modules))) if include_modules is not None: tent_mod_paths = self._modulemgr.get_and_clear_paths() @@ -129,8 +129,8 @@ def _module_inspect(self, obj): elif type(obj).__name__ == 'cython_function_or_method': members = inspect.getmembers(obj) for k, v in members: - if k == '__code__' and hasattr(v, 'co_filename'): - mods.add(v.co_filename.replace('.py', '')) + if k == '__globals__': + mods.add(v['__file__']) else: # The obj is the user's function but in form of a class