A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/068950.html below:

locking files on freebsd

locking files on freebsdHaris Lekasas Haris_member at newsranger.com
Tue Apr 3 09:14:23 EDT 2001
Thanks it seems
fcntl.lockf(f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB, 8192, 0, 0)
will do the job..
Haris

In article <9aafdf$dv6$1 at nntp6.u.washington.edu>, Donn Cave says...
>
>Quoth Haris Lekatsas <Haris_member at newsranger.com>:
>| Hello,
>| I have a problem with locking files. The following code will work on several OS
>| but it seems
>| to fail on FreeBSD giving an IOError.
>| Any ideas?
>|
>| f = open('filename', 'w')
>| fd = f.fileno()
>| flock = struct.pack('2h8l', FCNTL.F_WRLCK, 0, 0, 0, 0, 0, 0, 0, 0, 0)
>| fcntl.fcntl(fd, FCNTL.F_SETLKW, flock)
>
>The struct is the wrong size (and order.)  Look at /usr/include/fcntl.h
>to see the struct layout (at least, that's where I find it on NetBSD 1.5,
>whose struct comes out to only 24 bytes, as opposed to the 36 bytes
>generated by your format.)
>
>If it works for you, it would be easier to use fcntl.lockf().  The
>Python implementation of that function handles the flock struct itself,
>and borrows the API of the Berkeley flock() function.  The lockf()
>function is X/Open standard, and works with the same locks (and same
>twisted semantics) as the fcntl POSIX 1003.1 F_WRLCK;  I would say
>it's a wrapper around the latter, but I'm not sure it always is.
>
>	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4