网络驱动器上的python fsync()挂起

时间:2014-12-16 10:55:27

标签: python linux mount cifs fsync

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

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 个答案:

答案 0 :(得分:1)

您可以尝试设置nostrictsync挂载选项。

https://www.kernel.org/doc/readme/Documentation-filesystems-cifs-README有一些相关信息。