Python 2.7 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Python.
Stay organized with collections
Save and categorize content based on your preferences.
google.appengine.api.runtime.runtime module
Summary
Runtime Utilities API.
Deprecated since version 1.8.1.
Utilities for interacting with the Python Runtime.
Contents
- google.appengine.api.runtime.runtime.cpu_usage()source
-
Returns a SystemStat describing cpu usage, expressed in mcycles.
The returned object has the following accessors:
-
total(): total mcycles consumed by this instance
-
rate1m(): average mcycles consumed per second over the last minute
-
rate10m(): average mcycles consumed per second over the last ten minutes
Functions for converting from mcycles to cpu-seconds are located in the quotas
API.
- google.appengine.api.runtime.runtime.is_shutting_down()source
-
Returns true if the server is shutting down.
- google.appengine.api.runtime.runtime.memory_usage()source
-
Returns a SystemStat describing memory usage, expressed in MB.
The returned object has the following accessors:
-
current(): memory currently used by this instance
-
average1m(): average memory use, over the last minute
-
average10m(): average memory use, over the last ten minutes
- google.appengine.api.runtime.runtime.set_shutdown_hook(hook)source
Registers a function to be called when the server is shutting down.
The shutdown hook will be called when the server shuts down. Your code
will have a short amount of time to save state and exit. The shutdown
hook should interrupt any long running code you have, e.g. by calling
apiproxy_stub_map.apiproxy.CancelApiCalls and/or raising an exception.
ParametersReturnsThe previously registered shutdown hook, or None if no hook was
registered before.
In some cases it may not be possible to run the shutdown hook
before the server exits.
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-06-16 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-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003egoogle.appengine.api.runtime.runtime\u003c/code\u003e module provides utilities for interacting with the Python runtime environment, but it has been deprecated since version 1.8.1.\u003c/p\u003e\n"],["\u003cp\u003eThis module offers functions to retrieve CPU usage data, including total mcycles, and average mcycles consumed per second over one and ten minutes, using the \u003ccode\u003ecpu_usage()\u003c/code\u003e function.\u003c/p\u003e\n"],["\u003cp\u003eIt also includes \u003ccode\u003ememory_usage()\u003c/code\u003e which allows retrieving memory usage in MB, including current usage and averages over the last one and ten minutes.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eis_shutting_down()\u003c/code\u003e function is provided to check if the server is in the process of shutting down.\u003c/p\u003e\n"],["\u003cp\u003eA shutdown hook can be registered via \u003ccode\u003eset_shutdown_hook()\u003c/code\u003e to execute a specific function when the server shuts down, providing a short window to save state and exit.\u003c/p\u003e\n"]]],[],null,[]]