Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.
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.

Parameters
  • hook – A no-argument callable which will be called when the server is

  • down. (shutting) –

Returns

The 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.