Help: using msvcrt for file locking

Bengt Richter bokr at accessone.com
Sun Aug 26 06:23:22 EDT 2001


On Sat, 25 Aug 2001 23:25:42 -0400, "Tim Peters" <tim.one at home.com> wrote:

>[Sheila King]
>> I'm trying to do some file locking on Windows. I'm running Win98, but I
>> hope that the methods in the msvcrt module will work OK on any win32?
>
>msvcrt directly exposes some library functions supplied by, and unique to,
>Microsoft.  So, like it or not (I don't like it myself <wink>), Microsoft is
>the only entity who can answer questions about them with authority.  FWIW,
>the docs MS supplied with MSVC 6 say their _locking function works under
>"Win 95, Win NT", which *usually* means "everything after Win 3.1".
>
>Also as usual, the functions MS provides as part of their C library are a
>feeble subset of what you can do by using the Win32 API directly, in this
>case by using the Win32 LockFile and LockFileEx functions.  I don't know
>whether win32all exposes those specific functions; core Python does not.
>
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.




More information about the Python-list mailing list