Adding a bunch of flush statements to print as much to the log file as possible before python terminates the process when it's hanging