Activity log for bug #133080

Date Who What changed Old value New value Message
2007-08-17 03:14:38 Mythin bug added bug
2007-08-17 03:16:14 Mythin description pstats.py was changed either in python 2.4 or 2.5 to print out to it's own self.stream which is pointed at sys.stdout when the object is first initialized. This break the capturestdout class with web.profiler. The sys.stdout needs to be redirected before the object is created: class Profile: """ Profiles `func` and returns a tuple containing its output and a string with human-readable profiling information. >>> import time >>> out, inf = profile(time.sleep)(.001) >>> out >>> inf[:10].strip() 'took 0.0' """ def __init__(self, func): self.func = func def __call__(self, *args): ##, **kw): kw unused import hotshot, hotshot.stats, tempfile ##, time already imported temp = tempfile.NamedTemporaryFile() prof = hotshot.Profile(temp.name) stime = time.time() result = prof.runcall(self.func, *args) stime = time.time() - stime prof.close() from cStringIO import StringIO # Not threadsafe! out = StringIO() oldstdout = sys.stdout sys.stdout = out try: stats = hotshot.stats.load(temp.name) stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(40) stats.print_callers() x = '\n\ntook '+ str(stime) + ' seconds\n' x += out.getvalue() finally: sys.stdout = oldstdout return result, x pstats.py was changed either in python 2.4 or 2.5 to print out to it's own self.stream which is pointed at sys.stdout when the object is first initialized. This break the capturestdout class with web.profiler. The sys.stdout needs to be redirected before the object is created: class Profile: """ Profiles `func` and returns a tuple containing its output and a string with human-readable profiling information. >>> import time >>> out, inf = profile(time.sleep)(.001) >>> out >>> inf[:10].strip() 'took 0.0' """ def __init__(self, func): self.func = func def __call__(self, *args): ##, **kw): kw unused import hotshot, hotshot.stats, tempfile ##, time already imported temp = tempfile.NamedTemporaryFile() prof = hotshot.Profile(temp.name) stime = time.time() result = prof.runcall(self.func, *args) stime = time.time() - stime prof.close() from cStringIO import StringIO # Not threadsafe! out = StringIO() oldstdout = sys.stdout sys.stdout = out try: stats = hotshot.stats.load(temp.name) stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(40) stats.print_callers() x = '\n\ntook '+ str(stime) + ' seconds\n' x += out.getvalue() finally: sys.stdout = oldstdout return result, x
2007-08-17 15:55:43 Aaron Swartz webpy: status New Confirmed
2007-08-17 15:55:43 Aaron Swartz webpy: importance Undecided Medium
2007-08-17 15:55:43 Aaron Swartz webpy: statusexplanation
2007-08-17 15:55:43 Aaron Swartz webpy: assignee anandology
2007-12-24 15:07:58 Anand Chitipothu webpy: status Confirmed Fix Committed
2007-12-24 15:07:58 Anand Chitipothu webpy: milestone 0.23
2008-01-19 12:55:04 Anand Chitipothu webpy: status Fix Committed Fix Released