win32 file locking

John A Meinel john at
Wed May 25 04:37:29 BST 2005

It turns out there is a python module called "msvcrt" on python 2.3 and
2.4 (and maybe more).

Anyway, it has the msvcrt.locking() function which allows you to
set/release file locks.

Now, it turns out that these are always RW locks, though they allow
locking/unlocking block ranges instead of just the whole file.

On the other hand, if you have win32all installed (which is recommended
on the python download page) you can have access to the windows
"LockFileEx" function. This lets you chose the lock type, and also has
better functions for declaring what range is locked (though I would just
lock the whole file always).

Anyway, I'm thinking to rewrite it so that it tries to obtain the lock
with win32all, failing that it will use msvcrt, does that sound reasonable?

Also, I noticed that Branch() does not automatically unlock the lockfile
when it is done. Shouldn't that be done in the deconstructor?

(And by the way, you weren't importing 'warning' from bzrlib.trace,
though it was being used.)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : 

More information about the bazaar mailing list