~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/middleware/profile.py

  • Committer: Matt Nordhoff
  • Date: 2009-06-09 03:41:07 UTC
  • mfrom: (345.2.8 valid-feed)
  • Revision ID: mnordhoff@mattnordhoff.com-20090609034107-khjku04mzj36vumr
Make the Atom feeds (nearly) valid (bug #247162)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Profiling middleware for Paste."""
2
 
 
 
1
'''Profiling middleware for paste.'''
 
2
import cgi
 
3
import logging
 
4
import sys
3
5
import threading
4
6
 
5
7
from bzrlib.lsprof import profile
6
 
 
 
8
from guppy import hpy
7
9
 
8
10
class LSProfMiddleware(object):
9
 
    """Paste middleware for profiling with lsprof."""
 
11
    '''Paste middleware for profiling with lsprof.'''
10
12
 
11
13
    def __init__(self, app, global_conf=None):
12
14
        self.app = app
27
29
        try:
28
30
            ret, stats = profile(self.__run_app, environ, start_response)
29
31
            self.__count += 1
30
 
            stats.save("%d-stats.callgrind" % (self.__count,), format="callgrind")
 
32
            stats.save("%d-stats.callgrind" % self.__count, format="callgrind")
31
33
            return ret
32
34
        finally:
33
35
            self.lock.release()
 
36
 
 
37