Mickael_86130
Mickael_86130

Reputation: 213

python fsync() on network drive hangs

I write some data to a file using the following function:

def WriteTo1File(self, output_file, text):
    output_file.write(text)
    output_file.flush()
    os.fsync(output_file.fileno())

The fsync() call is mandatory to handle IOError: if I don't use it when a network drive is unreachable, the function write() works on its local buffer and raises no exceptions.

The problem is that after a few write operations, the function fsync() hangs. What is it related to? The local machine is Linux running python 2.7. The drives are mounted with mount.cifs. The remote disk is on a local server which is always reachable. If I unmount the remote disk, fsync() returns after few tens of seconds.

Upvotes: 3

Views: 757

Answers (1)

mhawke
mhawke

Reputation: 87074

You could try setting the nostrictsync mount option.

There is some information regarding this at https://www.kernel.org/doc/readme/Documentation-filesystems-cifs-README.

Upvotes: 1

Related Questions