Jim Gallacher
jpg at jgassociates.ca
Wed Sep 6 07:45:14 EDT 2006
Ethan Toan Ton wrote: > Mike, > > Thanks for the help. req.flush() works for sending out the data. > Unfortunately, at the same time, my python program is making requests and > receiving data from other http sources at the same time. When I run the > req.flush(), it outputs some of the incoming data as well. Not sure why > that is happening. That doesn't make any sense at all. Perhaps you can give a concrete example? Method req.flush() is a simple wrapper around the Apache ap_rflush() call. Note that you can also use req.write(some_string, flush=1) to immediately flush the output. For flush=1 causes ap_rflush() to be called as well. Jim > Ethan > > >> Your output is buffered in multiple stages. In most cases, you can call >> "req.flush()" to send data to the client. This will usually work, unless >> you have a module or a filter installed that collects output until the >> final stage. >> >> For example, this pattern shows how to send output from a slow query >> back to the user, so that he can see the results as they come back. By >> calling req.flush() at smart points, we make sure there's some feedback >> quite efficiently. >> >> ... >> req.write("<P>Results:</P><table><tr><th>Name</th><th>Date</th></tr>") >> req.flush() >> c=database.cursor() >> c.execute("SELECT name,date FROM persons") >> while 1: >> data = c.fetchmany() >> if not data: >> break >> for row in data: >> req.write("<tr><td>%s</td><td>%s</td></tr>" % row) >> req.flush() >> req.write("</table>") >> ... >> >> >> Mike Looijmans >> Philips Natlab / Topic Automation >> >> >> Ethan Toan Ton wrote: >>> I was wondering if anyone knew of a way to return multiple times to a >>> client using a Mod-Python event handler. Using the req.write() method >>> does nothing until the actual return statement sends all the data in one >>> message back to the client. So before you get to the actual return >>> statement, can you output back to them more than once? >> _______________________________________________ >> Mod_python mailing list >> Mod_python at modpython.org >> http://mailman.modpython.org/mailman/listinfo/mod_python >> > > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python >
|