Help: using msvcrt for file locking
Sheila King
sheila at spamcop.net
Sun Aug 26 11:19:20 EDT 2001
On Sun, 26 Aug 2001 10:23:22 GMT, bokr at accessone.com (Bengt Richter)
wrote in comp.lang.python in article
<3b88ceaa.496940252 at wa.news.verio.net>:
:I'm wondering if _locking requires using _sopen? The Python builtin open uses
:fopen as part of creating the file object, I believe. Example code in
:the msvc++6.0 help re _locking uses _sopen, which provides shared access control.
Hmm. This may be the case???
In an interactive session, when I try to acquire two non-blocking locks:
>>> import os
>>> filename = r'e:\apache\cgi-bin\pylinks\lock.txt'
>>> size = os.path.getsize(filename)
>>> f = open(filename)
>>> fd = f.fileno()
>>> msvcrt.locking(fd, msvcrt.LK_NBLCK, size)
>>> g = open(filename)
>>> gd = g.fileno()
>>> msvcrt.locking(gd, msvcrt.LK_NBLCK, size)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
IOError: [Errno 13] Permission denied
>>>
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/
More information about the Python-list
mailing list