This may be a duplicate of another question. It seems like you might have two issues: having a timer that triggers at a reliable interval (best handled through threading and the time.sleep()
function), and forcing output while the processor is busy.
For this latter issue, the best tool is sys.stdout.flush()
which pushes output to the current output device (this could be your console, or the iPython notebook output screen). This also works to print output from a function that has been called- useful if your computations are wrapped in another function.
Sample code:
import sys
def print_this(mystr):
print(mystr)
sys.stdout.flush()
for i in range(1,100)
print_this('hello world!')