fcntl.flock problems on FreeBSD

sblakey at freei.com sblakey at freei.com
Wed May 17 14:42:28 EDT 2000


I'm having some trouble with flock in the fcntl module on a FreeBSD 4.0
box.  Most of the flock operations work perfectly (LOCK_SH, LOCK_EX,
LOCK_UN), but LOCK_NB seems to alway raise a Bad file descriptor error.

Is this a bug in the fcntl module or a knwon deficiency of FreeBSD?
Does this OS not support non-blocking file locks.

I've implemented a workaround (this has to get out the door today), but
it feels like just that, a workaround.  Does anybody know what's wrong
here?

I replicated the problem in the interactive shell.
$ python
Python 1.5.2 (#2, Mar 12 2000, 12:38:38) [GCC 2.95.2 19991024 (release)]
on freebsd4
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import fcntl
>>> fd = open('lock', 'w')
>>> fcntl.flock(fd.fileno(), fcntl.LOCK_SH)
>>> fcntl.flock(fd.fileno(), fcntl.LOCK_EX)
>>> fcntl.flock(fd.fileno(), fcntl.LOCK_UN)
>>> fcntl.flock(fd.fileno(), fcntl.LOCK_NB)
Traceback (innermost lasr):
  File "<stdin>", line 1, in ?
IOError: [Errno 9] Bad file descriptor
>>>

	-Sean Blakey




More information about the Python-list mailing list