web.profiler does not work on Windows
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
web.py |
Fix Released
|
Low
|
Anand Chitipothu |
Bug Description
As discussed here, web.profiler fails to create temporary file on Windows.
http://
Ben Corneu suggested this fix:
-----------
looks like it's a bug in utils.py. It uses
tempfile.
file cannot be opened a second time. Using tempfile.mkstemp() instead
works but you lose the guaranteed cleanup of the temp file.
http://
...Whether the name can be used to open the file a second time, while
the named temporary file is still open, varies across platforms (it can
be so used on Unix; it cannot on Windows NT or later)....
here's my fix for it.
Line 733 of utils.py
def __call__(self, *args): ##, **kw): kw unused
import hotshot, hotshot.stats, tempfile, os ##, time already
imported
temp = tempfile.mkstemp()
prof = hotshot.
stime = time.time()
result = prof.runcall(
stime = time.time() - stime
import cStringIO
out = cStringIO.
stats = hotshot.
#delete the temp file as son as we are done with it
x = '\n\ntook '+ str(stime) + ' seconds\n'
x += out.getvalue()
return result, x
----------
Changed in webpy: | |
assignee: | nobody → anandology |
status: | New → Confirmed |
Changed in webpy: | |
importance: | Undecided → Low |
milestone: | none → 0.33 |
Changed in webpy: | |
status: | Fix Committed → Fix Released |
Fixed.
http:// github. com/webpy/ webpy/commit/ 25854c5828b1da4 af0f5432004ea44 8455a25f15