Question

My problem is that logging stops for a python program when the log is rotated. I have tracked it down to the stream itself. I don't see any way to tell if the stream is broken from python. After the file is deleted it still accepts writes without any issue.

import os

FILE = 'testing.txt'

fs = open(FILE, 'a')
fs.write('word')
os.remove(FILE)
fs.write('Nothing....') # Nothing breaks
print(fs.errors) # No errors

So, how can I find out if the file stream is still valid? And checking to see if the file exists will not help since the file will always exist regardless of whether or not the stream is still valid.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top