I want to write to the file in real time(instead of waiting for the code to finish) by flushing, but it doesn't seem to change anything. Here's the code:
dataFile =open("json",'a+')
def write(data):
dataFile.write(data)
dataFile.flush()
also dataFile.close()
didn't change anything. Does anyone know what the problem is?
EDIT:
I managed to make it work by adding os.fsync(dataFile.fileno())
right after dataFile.flush()