Python在网络驱动器上执行fsync()操作会卡住(hangs)

3

我使用以下函数将一些数据写入文件:

def WriteTo1File(self, output_file, text):
    output_file.write(text)
    output_file.flush()
    os.fsync(output_file.fileno())
fsync()调用是处理IOError的必要操作:如果在网络驱动器不可达时我不使用它,函数write()将在本地缓冲区上运行并且不会引发任何异常。
问题在于,在几次写操作之后,fsync()函数挂起。与什么有关呢?本地机器是运行Python 2.7的Linux。驱动器是通过mount.cifs挂载的。远程磁盘位于始终可访问的本地服务器上。如果卸载远程磁盘,fsync()在几十秒后返回。
1个回答

1

谢谢,但是如果我用这种方式挂载磁盘,我会得到相同的结果:sudo /usr/bin/mount.cifs //server_ip/disk_name /home/mika/todo/local_name/ -o cred=/home/mika/todo/.credentials,rw,uid=1000,gid=1000,iocharset=utf8,nostrictsync - Mickael_86130

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接