Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

Using the Modules API

This API is supported for first-generation runtimes and can be used whenupgrading to corresponding second-generation runtimes. If you are updating to the App Engine Python 3 runtime, refer to themigration guide to learn about your migration options for legacy bundled services.

The Modules API provides functions that return information about the currentoperating environment (module, version, and instance).

The Modules API also has functions that retrieve the address of a module, aversion, or an instance. This allows an application to send requests from oneinstance to another, in both the development and production environments.

You must import thegoogle.appengine.api.modules module from the SDK.

fromgoogle.appengine.apiimportmodules

The following code sample shows how to get the module name and instance id fora request:

module=modules.get_current_module_name()instance_id=modules.get_current_instance_id()self.response.write('module_id={}&instance_id={}'.format(module,instance_id))

The instance ID of an automatic scaled module will be returned as a uniquebase64 encoded value, e.g.e4b565394caa.

You can communicate between modules in the same app by fetching the hostname ofthe target module:

backend_hostname=modules.get_hostname(module='my-backend')url="http://{}/".format(backend_hostname)try:result=urllib2.urlopen(url).read()self.response.write('Got response{}'.format(result))excepturllib2.URLError:pass

You can also use theURL Fetch service.

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

Last updated 2025-12-15 UTC.