Hello,
Python 3.11.6
cryptography==41.0.7 installed using pip
cffi==1.16.0
pip 23.3.1
I am trying to use the fernet lib in a temporal worker, and keep getting the following issue due to PyO3 modules being instantiated twice. it seems that temporal is attempting to import and re-initization extension modules
stacktrace
> File "/crypto_utils.py", line 28, in _decrypt
> return fernet.decrypt(to_decrypt).decode()
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/lib/python3.11/site-packages/cryptography/fernet.py", line 91, in decrypt
> return self._decrypt_data(data, timestamp, time_info)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/lib/python3.11/site-packages/cryptography/fernet.py", line 152, in _decrypt_data
> self._verify_signature(data)
> File "/lib/python3.11/site-packages/cryptography/fernet.py", line 131, in _verify_signature
> h = HMAC(self._signing_key, hashes.SHA256())
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/lib/python3.11/site-packages/cryptography/utils.py", line 48, in _extract_buffer_length
> from cryptography.hazmat.bindings._rust import _openssl
> File "/lib/python3.11/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 441, in **call**
> return self.current(*args, **kwargs)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/lib/python3.11/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 234, in _import
> mod = importlib.**import**(name, globals, locals, fromlist, level)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "", line 1283, in **import**
> File "", line 1204, in _gcd_import
> File "", line 1176, in _find_and_load
> File "", line 1147, in _find_and_load_unlocked
> File "", line 676, in _load_unlocked
> File "", line 573, in module_from_spec
> File "", line 1233, in create_module
> File "", line 241, in _call_with_frames_removed
> ImportError: PyO3 modules may only be initialized once per interpreter process