[Tutor] IOError: (0, 'Error')

Bernard Lebel 3dbernard at gmail.com
Mon Jan 2 21:49:59 CET 2006


On 1/2/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
>
> > Everytime the program has to add a line is added to the file, the file
> > is open, appended, then closed, in order to be able to read it at any
> > point in time. This set of operations can happen several times a second,
> > like 1-10 or so. In this case, every query to a MySQL database is
> > printed, plus a few lines about the instance attributes.
>
> Hi Bernard,
>
> Hmm... weird.  Quick question: is the program multithreaded?

[Bernard] Hi Danny,

The program is indeed multi-threaded, although there is only one child
thread running..... The parent thread runs a while loop that writes to
the log every 5 seconds.

I think I see where you are going with this. Are you suggesting that
both parent and child thread might be trying to write to the log at
once, and one of them is closing the file while it is open for both?

That would make perfect sense, I had the same problem with database
connections. I worked around the problem by having a seperate
connection object, wich works very well.

However, in the case of the log, there can only be one file. I don't
know how I can "queue" the writing. So far I have prevented the error
from occuring with a try/except statement, but that is not a very
clean way of doing it, isn't?

Any suggestion is welcomed!


Thanks!
Bernard


More information about the Tutor mailing list