A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/appengine/migration-center/standard/python/migrate-outbound-requests below:

Migrating outbound requests | App Engine migration center

Skip to main content Migrating outbound requests

Stay organized with collections Save and categorize content based on your preferences.

By default, the Python 2.7 runtime uses the URL Fetch service to handle outbound HTTP(S) requests, even if you use the urllib, urllib2, or httplib Python libraries to issue those requests. URL Fetch does not handle requests from the requests library unless you explicitly enable it.

The Python 3 runtime doesn't need an intermediary service to handle outbound requests. If you want to migrate away from using URL Fetch APIs but still need similar functionality, you should migrate those requests to use a standard Python library such as the requests library.

Key differences between URL Fetch and standard Python libraries Overview of the migration process
  1. If your app uses URL Fetch APIs to make requests, update your code to use a standard Python library instead. We recommend that you specify a timeout for each request.

  2. Test your outbound requests in the local development server.

  3. Configure your app to bypass URL Fetch when running in App Engine.

  4. Deploy your app.

Replacing URL Fetch APIs with a Python library
  1. If you aren't already using a standard Python library to issue outgoing requests, choose a library and add it to your app's dependencies.

    For example, to use the Requests library create a requirements.txt file in the same folder as your app.yaml file and add the following line:

    requests==2.24.0
    

    For compatibility with Python 2, we recommend you pin the requests library to version 2.24.0. When you deploy your app, App Engine will download all of the dependencies that are defined in the requirements.txt file.

    For local development, we recommend that you install dependencies in a virtual environment such as venv.

  2. Search your code for any use of the google.appengine.api.urlfetch module, and update the code to use your Python library.

Making simple HTTPS requests

The following example shows how to make a standard HTTPS request using the requests library:

Making asynchronous HTTPS requests

The following example shows how to make an asynchronous HTTPS request using the requests library:

Testing locally

If you updated any of your outbound requests, run your app in the local development server and confirm that the requests succeed.

Bypassing URL Fetch

To stop URL Fetch from handling requests when you deploy your app to App Engine:

  1. In your app.yaml file, set the GAE_USE_SOCKETS_HTTPLIB environment variable to any value. The value can be any value including an empty string. For example:

    env_variables:
      GAE_USE_SOCKETS_HTTPLIB : ''
    
  2. If you enabled URL Fetch to handle requests sent from the requests library, you can remove the Requests AppEngineAdapter from your app.

    For example, remove requests_toolbelt.adapters.appengine from your appengine_config.py file and requests_toolbelt.adapters.appengine.monkeypatch() from your Python files.

Note that even if you bypass URL Fetch as described in the previous steps, your app can still use the URL Fetch API directly.

Deploying your app

Once you are ready to deploy your app, you should:

  1. Test the app on App Engine.

    View the App Engine Quotas page in the Google Cloud console to confirm that your app isn't making Url Fetch API Calls.

    View URL Fetch API Calls

  2. If the app runs without errors, use traffic splitting to slowly ramp up traffic for your updated app. Monitor the app closely for any issues before routing more traffic to the updated app.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Python 2.7 uses the URL Fetch service for outbound HTTP(S) requests by default, but the Python 3 runtime does not require this intermediary, allowing the use of standard Python libraries like `requests`."],["Requests handled by URL Fetch have different size limits and quotas compared to requests managed by standard Python libraries, so migrating to standard libraries changes these constraints."],["Migrating away from URL Fetch involves updating code to use standard Python libraries, testing these requests in a local server, configuring the app to bypass URL Fetch, and deploying the updated application."],["URL Fetch adds an `X-Appengine-Inbound-Appid` header for requests between App Engine apps to verify identity, a feature that is not present when using standard Python libraries, necessitating a migration to other methods of identity verification if required."],["When migrating from URL fetch, it is recommended to specify a timeout for each request, as standard libraries like `requests` and `urllib` set the default timeout to `None`, whereas URL Fetch allows setting a default timeout for all requests."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4