Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 932
Mickael_86130 Avatar asked May 31 '26 10:05

Mickael_86130


1 Answers

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.

like image 106
mhawke Avatar answered Jun 02 '26 23:06

mhawke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!