avoiding file corruption

Bryan Olson fakeaddress at nowhere.org
Sun Aug 27 10:33:03 EDT 2006


Amir Michail wrote:
> Trying to open a file for writing that is already open for writing
> should result in an exception.
> 
> It's all too easy to accidentally open a shelve for writing twice and
> this can lead to hard to track down database corruption errors.

The right solution is file locking. Unfortunately, the Python
tandard distribution doesn't have a portable file lock, but you
can do it on Unix and Win NT or better. See:

     http://mail.python.org/pipermail/python-win32/2005-February/002957.html

and/or

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203.


-- 
--Bryan



More information about the Python-list mailing list