safe simultaneous file append?
Chris Gonnerman
chris.gonnerman at newcenturycomputers.net
Mon Oct 8 08:06:21 EDT 2001
----- Original Message -----
From: "Dale Strickland-Clark" <dale at riverhall.NOSPAMco.uk>
>
> Erk! There's a recipee for disaster unless treated very carefully.
>
> Handy if you're careful, though, I guess.
Huh. I've used this feature for years under a variety of Unixoids
with no problem.
The only thing you need to do for safety is to ensure that complete
messages are written by a single write(2) call. Do this:
logfile.write("A long message...\n")
rather than this:
logfile.write("A ")
logfile.write("long message...")
logfile.write("\n")
(for instance)
It wouldn't hurt to add
logfile.flush()
after each write.
I have a logfile assistant in my Python Plumber's Helpers at
http://newcenturycomputers.net/projects/plumbers.html
if anyone is interested.
More information about the Python-list
mailing list