The answer to this question implies that Python logs are flushed with every write.
My experience with Python 3.8.1 on Windows 10 is that there is some buffering happening.
I have implemented very simple logging based on the tutorial
import logging
<snip - other setup>
logging.basicConfig(filename='MyLog.txt', level=logging.DEBUG)
while True:
<snip - get the data>
if newdata == 1 :
print ("> ",DataString,sep='')
logging.info(datettime_string+' '+DataString)
New data appears once every several minutes, which prints and logs one line of text. As I watch the console output, and compare that to the logging file, I see a significant delay (several data updates) before the log file is updated. Is there a way I can set the logging file to unbuffered, or explicitly flush the log file?