[python-win32] File Locking: HELP

Jorgensen, Jens jens.jorgensen@tallan.com
Mon, 27 Aug 2001 15:02:30 -0500


You're not trying this in Win98 are you? Here's a little excerpt from 
the MSDN library:

Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h; include windows.h.
  Library: Use kernel32.lib.

Sheila King wrote:

>OK, after a discussion with Tim Peters and others in comp.lang.python
>about file locking and msvcrt, I've decided that I really won't be able
>to use msvcrt for successful file locking.
>
>So, I'm going to try to use the win32 extensions. I have a book on
>order, but it will be a while until it gets here.
>
>In the meantime, I was trying to run the portalocker.py code that is
>here:
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203
>
>And I get this error, when running it as __main__:
>
>Traceback (most recent call last):
>  File "E:\programs\LearningPython\fileIO\portalocker.py", line 107, in
>?
>    portalocker.lock(log, portalocker.LOCK_EX)
>  File "E:\programs\LearningPython\fileIO\portalocker.py", line 88, in
>lock
>    win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped)
>pywintypes.api_error: (120, 'LockFileEx', 'This function is only valid
>in Win32 mode.')
>
>Any ideas what might be causing this?
>
>--
>Sheila King
>http://www.thinkspot.net/sheila/
>http://www.k12groups.org/
>
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32@python.org
>http://mail.python.org/mailman/listinfo/python-win32
>


-- 
Jens B. Jorgensen
jens.jorgensen@tallan.com