Hi, I'd like to be able to lock directory access under windows. The following code work greatly with file or directory under POSIX system:
def flock(fd, blocking=False, exclusive=False):
if exclusive:
flags = fcntl.LOCK_EX
else:
flags = fcntl.LOCK_SH
if not blocking:
flags |= fcntl.LOCK_NB
fcntl.flock(fd, flags)
But I only find a way to perform lock access for file, not directory with the following code:
def flock(fd, blocking=False, exclusive=False):
if blocking:
flags = msvcrt.LK_NBLCK
else:
flags = msvcrt.LK_LOCK
msvcrt.locking(fd.fileno(), flags, os.path.getsize(fd.name))
Have you got any idea how to improve this code and be able to lock directory access ?
Bertrand