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.