Google App Engine#

This module provides a pool manager that uses Google App Engine’s URLFetch Service.

Example usage:

from urllib3 import PoolManager
from urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox

if is_appengine_sandbox():
    # AppEngineManager uses AppEngine's URLFetch API behind the scenes
    http = AppEngineManager()
else:
    # PoolManager uses a socket-level API behind the scenes
    http = PoolManager()

r = http.request('GET', 'https://google.com/')

There are limitations to the URLFetch service and it may not be the best choice for your application. There are three options for using urllib3 on Google App Engine:

  1. You can use AppEngineManager with URLFetch. URLFetch is cost-effective in many circumstances as long as your usage is within the limitations.

  2. You can use a normal PoolManager by enabling sockets. Sockets also have limitations and restrictions and have a lower free quota than URLFetch. To use sockets, be sure to specify the following in your app.yaml:

    env_variables:
        GAE_USE_SOCKETS_HTTPLIB : 'true'
    

3. If you are using App Engine Flexible, you can use the standard PoolManager without any configuration or special environment variables.

class urllib3.contrib.appengine.AppEngineManager(headers=None, retries=None, validate_certificate=True, urlfetch_retries=True)#

Bases: RequestMethods

Connection manager for Google App Engine sandbox applications.

This manager uses the URLFetch service directly instead of using the emulated httplib, and is subject to URLFetch limitations as described in the App Engine documentation here.

Notably it will raise an AppEnginePlatformError if:
  • URLFetch is not available.

  • If you attempt to use this on App Engine Flexible, as full socket support is available.

  • If a request size is more than 10 megabytes.

  • If a response size is more than 32 megabytes.

  • If you use an unsupported request method such as OPTIONS.

Beyond those cases, it will raise normal urllib3 errors.

urlopen(method, url, body=None, headers=None, retries=None, redirect=True, timeout=<object object>, **response_kw)#
exception urllib3.contrib.appengine.AppEnginePlatformError#

Bases: HTTPError

exception urllib3.contrib.appengine.AppEnginePlatformWarning#

Bases: HTTPWarning