Does the python implementation of flock work transparently along with standard C libraries? If I have two programs, one in Python and the other in C, trying acquire a lock on a single file will it work?
fcntl library is built directly on top of the standard C libraries; so on Linux
fcntl.flock() uses the
flock C function directly.
See the source code for the
#ifdef HAVE_FLOCK Py_BEGIN_ALLOW_THREADS ret = flock(fd, code); Py_END_ALLOW_THREADS
This is clearly stated in the
fcntl.flock() documentation as well:
Perform the lock operation op on file descriptor fd (file objects providing a
fileno()method are accepted as well). See the Unix manual flock(2) for details. (On some systems, this function is emulated using
So yes, it'll work.