You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However the vendored version of requests is still imported in aws_xray_sdk/ext/pynamodb/patch.py, resulting in an ImportError when trying to patch pynamodb.
Steps to reproduce:
from aws_xray_sdk.core import patch
patch(("pynamodb",))
Running this code with botocore >= 1.13 yields the following stack trace:
Traceback (most recent call last):
File "test_xray.py", line 3, in <module>
patch(("pynamodb",))
File "~/.venv/lib/site-packages/aws_xray_sdk/core/patcher.py", line 96, in patch
_patch_module(m, raise_errors)
File "~/.venv/lib/site-packages/aws_xray_sdk/core/patcher.py", line 105, in _patch_module
_patch(module_to_patch)
File "~/.venv/lib/site-packages/aws_xray_sdk/core/patcher.py", line 120, in _patch
imported_module = importlib.import_module(path)
File "~/.venv/lib/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "~/.venv/lib/site-packages/aws_xray_sdk/ext/pynamodb/__init__.py", line 1, in <module>
from .patch import patch
File "~/.venv/lib/site-packages/aws_xray_sdk/ext/pynamodb/patch.py", line 1, in <module>
import botocore.vendored.requests.sessions
ModuleNotFoundError: No module named 'botocore.vendored.requests.sessions'
The text was updated successfully, but these errors were encountered:
What version of PynamoDB are you using? We have internal code to selectively remove patching the vendored requests package based on the version of PynamoDB being used. Please refer to this link to see how that is done.
The logic ultimately relies on the transitive dependency version that PynamoDB is using, so if there's an edge case we are missing, we'd love to find a way to fix it.
This is with pynamodb 4.1.0 and aws_xray_sdk 2.4.2.
Edit: just checked your link, the issue is that botocore.vendored.requests.sessions is imported on the first line of the file. So the ModuleNotFound error is triggered before the patching logic can run. Probably (but I haven't tested) a simple solution would be to move the import statement within the else statement on line 23.
requests
was removed frombotocore
1.13 (see https://www.awsfeed.com/2019/10/01/removing-the-vendored-version-of-requests-from-botocore/)However the vendored version of
requests
is still imported inaws_xray_sdk/ext/pynamodb/patch.py
, resulting in anImportError
when trying to patch pynamodb.Steps to reproduce:
Running this code with botocore >= 1.13 yields the following stack trace:
The text was updated successfully, but these errors were encountered: