diff options
| author | ianb <devnull@localhost> | 2005-05-31 19:03:31 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-31 19:03:31 +0000 |
| commit | 6d2877dd2842689c791a3f500c31fbbe950f766f (patch) | |
| tree | e950e304fb7d46dcc87cd478256527db5b8b539e /paste/server.py | |
| parent | 25fe23e9d4a666b3e1d805a5d6f28050227bed4b (diff) | |
| download | paste-6d2877dd2842689c791a3f500c31fbbe950f766f.tar.gz | |
Added whole-server profiling, which has to be started at a different level than the middleware can do
Diffstat (limited to 'paste/server.py')
| -rwxr-xr-x | paste/server.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/paste/server.py b/paste/server.py index 980eb35..0d0388a 100755 --- a/paste/server.py +++ b/paste/server.py @@ -157,6 +157,8 @@ def run_server(conf, app): server_mod = get_server_mod(conf['server']) if conf['verbose']: print "Starting server." + if conf.get('profile_server'): + return run_server_profiled(conf, app, server_mod) try: server_mod.serve(conf, app) except KeyboardInterrupt: @@ -164,6 +166,22 @@ def run_server(conf, app): pass return 0 +def run_server_profiled(conf, app, server_mod): + import hotshot + try: + prof_filename = conf.get('profile_server_log', 'hotshot_server.log') + if conf['verbose']: + print 'Logging profiling to %s' % prof_filename + prof = hotshot.Profile(prof_filename) + try: + prof.runcall(server_mod.serve, conf, app) + finally: + prof.close() + except KeyboardInterrupt: + # This is an okay error + pass + return 0 + def load_conf(conf, filename, default=False): if isinstance(filename, (list, tuple)): for fn in filename: |
