diff --git a/src/urllib3/contrib/_appengine_environ.py b/src/urllib3/contrib/_appengine_environ.py index c909010bf2..119efaeeb6 100644 --- a/src/urllib3/contrib/_appengine_environ.py +++ b/src/urllib3/contrib/_appengine_environ.py @@ -6,27 +6,31 @@ def is_appengine(): - return is_local_appengine() or is_prod_appengine() or is_prod_appengine_mvms() + return "APPENGINE_RUNTIME" in os.environ def is_appengine_sandbox(): - return is_appengine() and not is_prod_appengine_mvms() + """Reports if the app is running in the first generation sandbox. + + The second generation runtimes are technically still in a sandbox, but it + is much less restrictive, so generally you shouldn't need to check for it. + see https://cloud.google.com/appengine/docs/standard/runtimes + """ + return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27" def is_local_appengine(): - return ( - "APPENGINE_RUNTIME" in os.environ - and "Development/" in os.environ["SERVER_SOFTWARE"] + return is_appengine() and os.environ.get("SERVER_SOFTWARE", "").startswith( + "Development/" ) def is_prod_appengine(): - return ( - "APPENGINE_RUNTIME" in os.environ - and "Google App Engine/" in os.environ["SERVER_SOFTWARE"] - and not is_prod_appengine_mvms() + return is_appengine() and os.environ.get("SERVER_SOFTWARE", "").startswith( + "Google App Engine/" ) def is_prod_appengine_mvms(): - return os.environ.get("GAE_VM", False) == "true" + """Deprecated.""" + return False diff --git a/src/urllib3/contrib/appengine.py b/src/urllib3/contrib/appengine.py index 01c91409f8..9b7044ffb0 100644 --- a/src/urllib3/contrib/appengine.py +++ b/src/urllib3/contrib/appengine.py @@ -108,13 +108,6 @@ def __init__( "URLFetch is not available in this environment." ) - if is_prod_appengine_mvms(): - raise AppEnginePlatformError( - "Use normal urllib3.PoolManager instead of AppEngineManager" - "on Managed VMs, as using URLFetch is not necessary in " - "this environment." - ) - warnings.warn( "urllib3 is using URLFetch on Google App Engine sandbox instead " "of sockets. To use sockets directly instead of URLFetch see "