2024-05-20 08:21:04 发布
网友
flock的python实现与标准C库一起透明地工作吗?如果我有两个程序,一个在Python中,另一个在C中,尝试获取一个文件的锁,它能工作吗?在
快速链接:
Python的fcntl库直接构建在标准C库之上;因此在Linux上fcntl.flock()直接使用flockC函数。在
fcntl
fcntl.flock()
flock
参见source code for the ^{} module:
#ifdef HAVE_FLOCK Py_BEGIN_ALLOW_THREADS ret = flock(fd, code); Py_END_ALLOW_THREADS
这在^{} documentation中也有明确说明:
fcntl.flock(fd, op) 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 fcntl().)
fcntl.flock(fd, op)
fileno()
fcntl()
所以是的,它会起作用的。在
Python的
fcntl
库直接构建在标准C库之上;因此在Linux上fcntl.flock()
直接使用flock
C函数。在参见source code for the ^{} module :
这在^{} documentation 中也有明确说明:
所以是的,它会起作用的。在
相关问题 更多 >
编程相关推荐