On Tue, Jun 29, 2010 at 6:17 PM, Graham Dumpleton < graham.dumple...@gmail.com> wrote:
> On 30 June 2010 02:14, Aaron Fransen <aaron.fran...@gmail.com> wrote: > > Couple more things I've been able to discern. > > > > The first happened after I "fixed" the html code. Originally under > > mod_python, I guess I was cheating more than a little bit by sending > > <html></html> code blocks twice, once for the incremental notices, once > for > > the final content. Once I changed the code to send a single properly > parsed > > block, the entire document showed up as expected, however it still did > not > > send any part of the html incrementally. > > > > Watching the line with Wireshark, all of the data was transmitted at the > > same time, so nothing was sent to the browser incrementally. > > > > (This is using the write() functionality, I haven't tried watching the > line > > with yield yet.) > > Use a variation of WSGI middleware wrapper in: > > > http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response > > using it to 'print' returned data to Apache log and then tail Apache > error log to see when that data is output. Alternatively, change the > code there to output a time stamp against each chunk of data written > to the file recording the response content. > > This will show what data is returned by WSGI application, before > mod_wsgi truncates anything greater than content length specified, > plus also show whether it is your WSGI application which is delaying > output somehow, or whether Apache output filters are doing it. > > Graham > I've actually tried a variation on this already using a built-in logging facility in the application that writes date/time values to an external log file with comments, and in the case of testing wsgi I actually included some time.sleep() statements to force a delay in the application. To give you an idea of the flow, here's essentially what's going on: def application(environ,start_response): mydict = {} mydict['environ']=environ mydict['startresponse'] = start_response # run program in another .py file that has been imported RunTest(mydict) Then in the other module you would have something like: def RunTest(mydict): status = '200 OK' response_headers = [('Content-type','text/html')] writeobj = detail['startresponse'](status,response_headers) writeobj('<html><body>Fetching sales for 2009...') time.sleep(2) writeobj('<br>Fetching sales for 2010...') ...then finally... writeobj('5000 results returned.</body></html>') return This is obviously a truncated (and fake) example, but it gives you an idea of the flow.
_______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com