I would like to be able to block access to the directory under the windows. The following code works very hard with a file or directory on a 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 do access blocking for a file, not a 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))
Do you have an idea how to improve this code and block access to the directory?
Bertrand
source share