about "i#52: lock database"

Ivan Glushkov gli.work at gmail.com
Mon May 14 14:57:57 PDT 2007


Hi.

The final decision should be the following.
1. DITrack.Util.Locking should provide our project with OS-independent way
for locking and unlocking of any files.
Functions in this module:
    * DITrack.Util.Locking.lock(file_descriptor) - lock file descriptor.
Doesn't return value.
       If this file descriptor has already been locked, raise some exception
(FileIsLockedError?)
    * DITrack.Util.Locking.unlock(file_descriptor) - unlock file descriptor.
Doesn't return value.

2. DITrack.DB.Common should provide the following funcions:
    * DITrack.DB.Common.lock(db_path) - lock the database directory. Doesn't
return values.
       This function should just create special file (.ditrack/LOCK for now)
write self pid into it and lock it, saving file descriptor.
       If errors occurs, exceptions would raise (in algorithm described by
Vlad in previous letter):
>       if there is no lock on the file,
>          raise DITrack.DB.Exceptions.DBStaleLockError
>       else
>          if there is sensible PID in the file,
>             raise DITrack.DB.Exceptions.DBIsLockedError(PID)
>          else
>             raise DITrack.DB.Exceptions.DBLockFileCorruptedError
    * DITrack.DB.Common.unlock() - unlock database. Doesn't return value.

Proposals?

Ivan


More information about the Dev mailing list