Discussion in 'Python' started by scriptlearner@gmail.com, Nov 8, 2008.

Guest

OS: Solaris 9
Python Version: 2.4.4

I need to log certain data in a worker thread; however, I am getting
an error now when I use two worker threads.
I think the problem comes from the line
logging.info('Thread Object (%d)%d), Time:%s in seconds %d'%
(self.no,self.duration,time.ctime(),time.time()))
when multiple worker thread is trying to update the log files.
What did I do wrong? Should I lock the log file before writing to
it? Thanks.

It would be helpful if you could post a complete script which shows
the problem. You should be doing a join for each of the threads
spawned in the main thread, as otherwise the main thread will exit
after the for loop and cause atexit processing to be done (which
causes logging handlers to be closed).

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!