title: Python: Lock directory access under windows
body: <p>I'd like to be able to lock directory access under windows.
  The following code work greatly with file or directory under POSIX system:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>But I only find a way to perform lock access for file, not directory with the following code:</p>
  
  <pre><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))
  </code></pre>
  
  <p>Have you got any idea how to improve this code and be able to lock directory access ?</p>
  
  <p>Bertrand</p>