concurrent access to object file

Frank Abel frankabel at tesla.cujae.edu.cu
Mon May 23 16:13:07 EDT 2005


Hi all!
I will build a HTTPServer and dislike that one request is handled at a time
(synchronous). So I write:

class MyHTTPServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):
    ....
    ....

For log the request and error I create a file and atteched it to the server
instance. Then the file log object can be see at RequestHandler instance
("self.server.log_file"). I overwrite in MyHTTPRequestHandler the methods
"log_message" to write instead of "sys.stderr" in my log file
"self.server.log_file".

My question is: Is posible that the log file crash (merge lines or some
other things) if two or more thread try to write in it "simultaneously" or
the write method of file object has a lock that prevent this?

Some other suggestion to get the aproach painted above?

Thank in advance
Frank








More information about the Python-list mailing list