-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arcgis package breaks boto3? #3912
Comments
Hi @thehappycheese thanks for reaching out. I could reproduce the issue as you described. Steps for quickly reproducing the issue: Set up a virtual environment:
In a new file: import boto3
import arcgis
boto3.client('s3') Results in: The error does not occur when importing arcgis before boto3 as you mentioned. It also does not occur if a client is not created. I tested this on Python 3.11.5/OpenSSL 1.1.1.u, but the error did not occur when I tested in Python 3.8.2/OpenSSL 1.1.1d. Have you tried testing in any other Python or OpenSSL versions? I couldn't find any other reports of this specific issue. I'm wondering if this is some edge case involving the boto3/arcgis dependencies or SSL context initialization. We can continue tracking this here and try to narrow down the cause. |
@nateprewitt pointed out to me that this is occurring because arcgis is modifying the urllib3 import in the global modules. If boto3 is imported after arcgis then that will correct the monkey patching we're doing. You can find a related issue here with how eventlet does monkeypatching: eventlet/eventlet#618. Based on that information, arcgis would need to make changes for this to be fixed. |
Hi @thehappycheese, thanks for raising this report. I did a cursory search and think I've got leads on why this specific issue is occurring with arcgis. Could you confirm if I unfortunately can't find the arcgis code hosted publicly to link to but if you dig through the modules after download, you can see they've integrated truststore (arcgis/auth/api.py) and are mutating the SSL library with My initial hypothesis from what we're seeing in the stacktrace is that we're hitting this issue because truststore is mutating the import for urllib3's SSLContext. When this is done after we've imported botocore, we end up in this recursive state. When it's done before the boto3 import, we're able to properly establish the correct reference to SSLContext. The reason you're likely hitting this in your environment is arcgis skips only uses truststore in Python 3.10+ on Windows. arcgis/auth/api.py
arcgis setup.py
So this does appear to be stemming from how arcgis is mutating the ssl module with truststore. We can likely work with the truststore maintainers to see if there's a way to get this smoothed out but for the time being arcgis will likely break anyone using the SSLContext from urllib3 if it's not imported first. |
I've opened sethmlarson/truststore#121 to track the issue in truststore with a minimal repro using only urllib3 and truststore. This may get addressed in a future truststore release but imports will likely need to be managed by customers using arcgis on newer version Python for now. |
I'm going to put this ticket back in auto-close since we seem to have answers to the underlying problem. Please feel free to let us know if you have any further questions though. We've been able to reproduce this issue with just arcgis and urllib3, so this does appear to be unique to how arcgis is using |
Hi @nateprewitt, thankyou for your work to get to the bottom of this! Really appreciate it.
Apologies for the delayed response and thanks again :) |
Hi, I'm facing the same issue. Introducing ArcGIS in my project broke my boto3 operations. Looking at the mentioned issues there doesn't seem to be a fix yet, is that right? I tried downgrading my project to python 3.9 and arcgis api operations now hang forever |
we're seeing this problem on our side, and the boto3 team has reproduced the issue and are actively looking into a solution. |
Describe the bug
If I import
arcgis
afterboto3
thenboto3
fails to create an s3 client.Does boto3 do any non-standard imports or monkey patching?
I cant tell if it is
boto3
orarcgis
causing the problem.Expected Behavior
It should not matter what order the packages are imported
Current Behavior
See
Reproduction Steps
below to see what caused this errorReproduction Steps
Possible Solution
A workaround is to swap the order of imports:
Additional Information/Context
I raised a similar issue on the arcgis package here: Esri/arcgis-python-api#1698
SDK version used
boto3 1.28.71
Environment details (OS name and version, etc.)
Windows 10, Freshly reinstalled Python 3.11.5
The text was updated successfully, but these errors were encountered: