I am running a Python script on a Rasberry Pi which appears to freeze intermittently on the print()
call. The script only freezes occasionally and continues when someone focuses on the terminal and presses the "enter" button or hits ctrl+c.
My guess is that the problem here is that the print()
call is waiting to get some kind of response back from the terminal which it doesn't get when the user does something unexpected, such as highlight text, right-click drag, or some other thing (which I am unable to replicate). To be clear, the script hangs indefinitely in this case, and not for the 120 seconds specified in the time.sleep() call directly below.
My question is this: is there any print call I can use in python which doesn't wait to get a response back from the console so that it doesn't freeze in unknown cases like the above?
I've put my code below, although the specifics of what it does are not particularly relevant to the question.
while True:
directory_pump_files = glob.glob("./pumplog*.csv") #read in some files from the file system
for file_path in directory_pump_files:
try_upload_file(file_path, pump_files_done, "/batchUpload/create") #upload the pump file
directory_log_files = glob.glob("./log*.csv")
for file_path in directory_log_files:
try_upload_file(file_path, log_files_done, "/batchUpload/SensorReadings") #upload the log file
print ("sleep")
time.sleep(120)