python fsync() on network drive hangs

738 views Asked by At

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.

1

There are 1 answers

1
mhawke On

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.