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

Alan Kennedy alanmk at hotmail.com
Thu Feb 28 07:41:03 EST 2002


shriek at gmx.co.uk (Stephen) wrote in message 
> I had a look at the effbot queue-example and think I understand the
> Queue class but adapting my program to share the queue instance in the
> first place is making my head spin.  Namely, how do I get the same
> Queue object into both MyHandler and MyServer in the first place ?

Stephen,

Jason Orendorff has already outlined a very similar method to the one
we use, so I won't repeat it here.

The only thing I would add is that we have a threadManager class whose
only job is to start, monitor, recreate and stop threads. This
includes the logging thread, so if the logging thread ever stops, the
threadMonitor will notice and start a replacement.

And in anticipation of people asking the question: "How do you stop
one thread from another", we do it very simply: we just send the
thread a "kill" message on its Queue, i.e. an object which tells the
thread to exit as soon as it receives the message.

Happy threading.

Alan.



More information about the Python-list mailing list