|
From: Gibhardt, H. <hg...@gw...> - 2011-11-17 09:00:24
|
Dear colleagues,
I am not sure, if this is the correct way to inform you from a specific
problematic behaviour of this module:
Situation:
1. I make experiments with detectors and motors - with python as control
software (on windows xp).
2. I use configobj to log changes of status (movement of motors etc.). For
years, all that works without problems.
3. Since a couple of weeks, I use robocopy in parallel to copy new generated
and changed files on a separate file server. This is done 47 times per day.
4. It happens that if robocopy copies the changed .ini file and at the same
time configobj wants to write new information into that file, that python
hangs up. (This happened once a week and to some time to find out).
Solution:
After hard work for finding the reason for the hang up, I came into the
configobj module and found the following: If the handler is made at first,
configobj uses safe methods for verifying the logfile. However, any attempt
to write into the ini file is done unsafe:
def write:
if outfile is not None:
outfile.write(output)
else:
h = open(self.filename, 'wb')
h.write(output)
h.close()
That means, file access is unsafe any time.
Now, I derived a new class from configobj and added a new function, which
only uses safe file access (with try blocks). And now, the problem is solved
and I see, that this happens once a week - but the error is catched.
I think, it would be better to do this in the original configobj module, as
the user takes it as whole and thinks, that it works well at any time. File
access should be safe.
However, thank you for this great module!
Holger
|