cgi "print statement" in multithreaded enviroment?

Irmen de Jong irmen.NOSPAM at xs4all.nl
Mon May 2 20:14:57 EDT 2005


vegetax wrote:
> How can i use cgi'like print statement in a multitreaded web framework?
> each thread has its own Servlet instance with request/response objects,
> sys.stdout = self.response(which is a file like object) wont work because
> all threads will set the same file object and it will be a concurrence
> mess.
> 
> I am out of ideas here,so any hacks welcome =)
> 

instead of:

    print "<html>.....</html>

do:

    print >>self.response, "<html>....</html>"


--Irmen



More information about the Python-list mailing list