I have a Python script on Windows which prints text to the cmd prompt every 60 seconds, but sometimes it hangs and doesn't print the text until I press the Return key.
Brief overview:
for i in xrange(10):
print str(datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')) + "A sentence which is output to the command prompt"
time.sleep(60)
Is this normal?
Edit:
I tried running Python with -u
(unbuffered mode) and added sys.stdout.flush()
after each print statement, some print statements cause the script to hang. I noticed this is happening on my Windows VMware & Virtualbox machines, but not a users ESXi Windows box. –