capturestdout in utils.py doesn't work with lighttpd fastcgi in some cases

Bug #135095 reported by Stephen
2
Affects Status Importance Assigned to Milestone
web.py
Fix Released
Undecided
Anand Chitipothu

Bug Description

Because capturestdout changes stdout, it causes lighttpd using fastcgi not to work for me. Additionally, changing a descriptor like this might not be thread-safe. Since capturestdout is used only once, attached is a patch that replaces the use of capturestdout in utils.py:

--- old/webpy/web/utils.py 2007-08-06 21:26:17.000000000 -0500
+++ new/webpy/web/utils.py 2007-08-27 11:01:01.000000000 -0500
@@ -617,6 +617,7 @@
         self.func = func
     def __call__(self, *args): ##, **kw): kw unused
         import hotshot, hotshot.stats, tempfile ##, time already imported
+ import cStringIO
         temp = tempfile.NamedTemporaryFile()
         prof = hotshot.Profile(temp.name)

@@ -629,8 +630,11 @@
         stats.strip_dirs()
         stats.sort_stats('time', 'calls')
         x = '\n\ntook '+ str(stime) + ' seconds\n'
- x += capturestdout(stats.print_stats)(40)
- x += capturestdout(stats.print_callers)()
+ out = cStringIO.StringIO()
+ stats.stream = out
+ stats.print_stats(40)
+ stats.print_callers()
+ x += out.getvalue()
         return result, x

 profile = Profile

Revision history for this message
Anand Chitipothu (anandology) wrote :
Changed in webpy:
assignee: nobody → anandology
milestone: none → 0.3
status: New → Fix Committed
Changed in webpy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.