Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Attributes
MoinMoin.web.profile.PycallgraphMiddleware Class Reference
Inheritance diagram for MoinMoin.web.profile.PycallgraphMiddleware:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.web.profile.PycallgraphMiddleware:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def run_profile
def shutdown
def profile

Public Attributes

 pycallgraph
 app

Private Attributes

 _filename
 _filter

Detailed Description

A call graphing middleware utilizing the pycallgraph 3rd party
module (available at http://pycallgraph.slowchop.com/). 

Definition at line 88 of file profile.py.


Constructor & Destructor Documentation

def MoinMoin.web.profile.PycallgraphMiddleware.__init__ (   self,
  app,
  filename 
)

Definition at line 91 of file profile.py.

00091 
00092     def __init__(self, app, filename):
00093         super(PycallgraphMiddleware, self).__init__(app)
00094         import pycallgraph
00095         pycallgraph.settings['include_stdlib'] = False
00096         self._filename = filename
00097         globs = ['pycallgraph.*', 'unknown.*']
00098         f = pycallgraph.GlobbingFilter(exclude=globs, max_depth=9999)
00099         self._filter = f
00100         self.pycallgraph = pycallgraph


Member Function Documentation

def MoinMoin.web.profile.ProfilerMiddleware.profile (   self,
  environ,
  start_response 
) [inherited]
Profile the request. Exceptions encountered during the profile are
logged before being propagated for further handling.

Definition at line 36 of file profile.py.

00036 
00037     def profile(self, environ, start_response):
00038         """
00039         Profile the request. Exceptions encountered during the profile are
00040         logged before being propagated for further handling.
00041         """
00042         method = environ.get('REQUEST_METHOD', 'GET')
00043         url = get_current_url(environ)
00044         logging.debug("Profiling call for '%s %s'", method, url)
00045         try:
00046             res = self.run_profile(self.app, (environ, start_response))
00047         except Exception, e:
00048             logging.exception("Exception while profiling '%s %s'", method, url)
00049             raise
00050         return res

Here is the call graph for this function:

def MoinMoin.web.profile.PycallgraphMiddleware.run_profile (   self,
  app,
  args,
  kwargs 
)
Override in subclasses.

Several profilers available for python use the same call signature,
therefore simplifying the implementation.

Reimplemented from MoinMoin.web.profile.ProfilerMiddleware.

Definition at line 101 of file profile.py.

00101 
00102     def run_profile(self, app, *args, **kwargs):
00103         pycallgraph = self.pycallgraph
00104         pycallgraph.start_trace(reset=True, filter_func=self._filter)
00105         try:
00106             return app(*args, **kwargs)
00107         finally:
00108             pycallgraph.stop_trace()

Override in subclasses to clean up when server/script shuts down. 

Reimplemented from MoinMoin.web.profile.ProfilerMiddleware.

Definition at line 109 of file profile.py.

00109 
00110     def shutdown(self):
00111         fname = self._filename
00112         pycallgraph = self.pycallgraph
00113         if fname.endswith('.png'):
00114             logging.info("Saving the rendered callgraph to '%s'", fname)
00115             pycallgraph.make_dot_graph(fname)
00116         elif fname.endswith('.dot'):
00117             logging.info("Saving the raw callgraph to '%s'", fname)
00118             pycallgraph.save_dot(fname)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 95 of file profile.py.

Definition at line 98 of file profile.py.

Definition at line 34 of file profile.py.

Definition at line 99 of file profile.py.


The documentation for this class was generated from the following file: