~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/middleware/profile.py

  • Committer: Andrew Bennetts
  • Date: 2011-06-28 10:58:27 UTC
  • Revision ID: andrew.bennetts@canonical.com-20110628105827-ybvrp9o7rx0o0z06
Fix test failure: Update test_controllers for recent changes to AnnotateUI.

Show diffs side-by-side

added added

removed removed

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