How to have multi-threaded server log to one file ?

Aahz Maruch aahz at panix.com
Wed Feb 27 00:32:18 EST 2002


In article <97ae44ee.0202261855.15c97708 at posting.google.com>,
Stephen <shriek at gmx.co.uk> wrote:
>
>When the server is run, each request from a client is handled by
>MyHandler() in a separate thread. If multiple requests are being run
>at the same time, how should I write my code so that they cal all
>write to the same log file without conflict ?  Should I use a global
>variable for the logfile, as below ~

Create a new thread for writing to the logfile and use Queue.Queue to
pass data to the writer thread.  See
http://starship.python.net/crew/aahz/
-- 
                      --- Aahz  <*>  (Copyright 2002 by aahz at pobox.com)

Hugs and backrubs -- I break Rule 6                 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista

"He's Quebecois. He puts mayonnaise on *everything*."  --siobhan at virulent.org



More information about the Python-list mailing list