<br><br><div class="gmail_quote">On Tue, Jun 29, 2010 at 6:17 PM, Graham Dumpleton <span dir="ltr"><<a href="mailto:graham.dumpleton@gmail.com">graham.dumpleton@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 30 June 2010 02:14, Aaron Fransen <<a href="mailto:aaron.fransen@gmail.com">aaron.fransen@gmail.com</a>> wrote:<br>
> Couple more things I've been able to discern.<br>
><br>
> The first happened after I "fixed" the html code. Originally under<br>
> mod_python, I guess I was cheating more than a little bit by sending<br>
> <html></html> code blocks twice, once for the incremental notices, once for<br>
> the final content. Once I changed the code to send a single properly parsed<br>
> block, the entire document showed up as expected, however it still did not<br>
> send any part of the html incrementally.<br>
><br>
> Watching the line with Wireshark, all of the data was transmitted at the<br>
> same time, so nothing was sent to the browser incrementally.<br>
><br>
> (This is using the write() functionality, I haven't tried watching the line<br>
> with yield yet.)<br>
<br>
</div>Use a variation of WSGI middleware wrapper in:<br>
<br>
<a href="http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response" target="_blank">http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response</a><br>
<br>
using it to 'print' returned data to Apache log and then tail Apache<br>
error log to see when that data is output. Alternatively, change the<br>
code there to output a time stamp against each chunk of data written<br>
to the file recording the response content.<br>
<br>
This will show what data is returned by WSGI application, before<br>
mod_wsgi truncates anything greater than content length specified,<br>
plus also show whether it is your WSGI application which is delaying<br>
output somehow, or whether Apache output filters are doing it.<br>
<font color="#888888"><br>
Graham<br>
</font></blockquote></div><br>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.<br>
<br>To give you an idea of the flow, here's essentially what's going on:<br><br>def application(environ,start_response):<br> mydict = {}<br> mydict['environ']=environ<br> mydict['startresponse'] = start_response<br>
# run program in another .py file that has been imported<br> RunTest(mydict)<br> <br>Then in the other module you would have something like:<br><br>def RunTest(mydict):<br> status = '200 OK'<br> response_headers = [('Content-type','text/html')]<br>
writeobj = detail['startresponse'](status,response_headers)<br> writeobj('<html><body>Fetching sales for 2009...')<br> time.sleep(2)<br> writeobj('<br>Fetching sales for 2010...')<br>
<br> ...then finally...<br><br> writeobj('5000 results returned.</body></html>')<br> return<br><br>This is obviously a truncated (and fake) example, but it gives you an idea of the flow.<br><br>