The problem is in the section of the code (starts at line 124) that writes the file.
with outfile:
try: outfile.write(self.data)
except IOError as exc: logging.error("Unable to write data to %s: %s", dest, exc) return False
else: outfile.flush() os.fsync(outfile.fileno()) return True
We only catch exceptions if they happen during *writing* the file, but in this case they were thrown in the "else" section, where we're no longer expecting them to happen.
Moving all file operations so they're inside the "try" section should help here, but we need to consider the implications and reasons why this was in the "else" section in the first place. IMHO clearly if the write operation failed, we don't need to flush and sync.
The problem is in the section of the code (starts at line 124) that writes the file.
with outfile:
outfile. write(self. data)
logging. error(" Unable to write data to %s: %s", dest, exc)
return False
outfile. flush()
os.fsync( outfile. fileno( ))
return True
try:
except IOError as exc:
else:
We only catch exceptions if they happen during *writing* the file, but in this case they were thrown in the "else" section, where we're no longer expecting them to happen.
Moving all file operations so they're inside the "try" section should help here, but we need to consider the implications and reasons why this was in the "else" section in the first place. IMHO clearly if the write operation failed, we don't need to flush and sync.