Commit 874ffa47 authored by Kirill Smelkov's avatar Kirill Smelkov

X ZPublisher: Fix profiling

- don't check if result is None: it is e.g. 200 when request was
  handlded OK.
- don't patch sys.stdout at runtime - PStats ignore that - patch
  stats.stream
parent d916c812
...@@ -425,18 +425,22 @@ def publish_module_profiled(module_name, stdin=sys.stdin, stdout=sys.stdout, ...@@ -425,18 +425,22 @@ def publish_module_profiled(module_name, stdin=sys.stdin, stdout=sys.stdout,
finally: finally:
_plock.release() _plock.release()
if result is None: #if result is None:
if True:
try: try:
error=sys.exc_info() error=sys.exc_info()
file=open(_pfile, 'w') file=open(_pfile, 'w')
file.write( file.write(
("# %s -> %s\n" % (path_info, result)) +
"See the url " "See the url "
"http://www.python.org/doc/current/lib/module-profile.html" "http://www.python.org/doc/current/lib/module-profile.html"
"\n for information on interpreting profiler statistics.\n\n" "\n for information on interpreting profiler statistics.\n\n"
) )
sys.stdout=file #sys.stdout=file
_pstat.strip_dirs().sort_stats('cumulative').print_stats(250) ps = _pstat.strip_dirs()
_pstat.strip_dirs().sort_stats('time').print_stats(250) ps.stream = file
ps.sort_stats('cumulative').print_stats(250)
ps.sort_stats('time').print_stats(250)
file.flush() file.flush()
file.close() file.close()
except: pass except: pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment