cherrypy.lib.gctools module

Garbage collection inspection tooling.

class cherrypy.lib.gctools.GCRoot[source]

Bases: object

A CherryPy page handler for testing reference leaks.

classes = [(<class 'cherrypy._cprequest.Request'>, 2, 2, 'Should be 1 in this request thread and 1 in the main thread.'), (<class 'cherrypy._cprequest.Response'>, 2, 2, 'Should be 1 in this request thread and 1 in the main thread.'), (<class 'cherrypy._cpwsgi.AppResponse'>, 1, 1, 'Should be 1 in this request thread only.')]
index()[source]

Render the index page HTML content.

stats()[source]

Render garbage collection statistics page HTML content.

class cherrypy.lib.gctools.ReferrerTree(ignore=None, maxdepth=2, maxparents=10)[source]

Bases: object

An object which gathers all referrers of an object to a given depth.

_format(obj, descend=True)[source]

Return a string representation of a single object.

ascend(obj, depth=1)[source]

Return a nested list containing referrers of the given object.

format(tree)[source]

Return a list of string reprs from a nested list of referrers.

peek(s)[source]

Return s, restricted to a sane length.

peek_length = 40
class cherrypy.lib.gctools.RequestCounter(bus)[source]

Bases: SimplePlugin

An HTTP request counter plugin.

after_request()[source]

Decrement the counter after HTTP request.

before_request()[source]

Increment the counter before HTTP request.

start()[source]

Initialize the internal counter.

cherrypy.lib.gctools.get_context(obj)[source]

Compute object’s runtime context information.

cherrypy.lib.gctools.get_instances(cls)[source]

Return GC instances.