1

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. –

mustaccio
  • 18,234
  • 16
  • 48
  • 57
mbudge
  • 557
  • 13
  • 28
  • Note that the `strftime` method will return a string already. – Ben Jun 07 '16 at 18:08
  • I tried running Python with -u (unbufferedmode) 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. – mbudge Jun 08 '16 at 12:12
  • Is it at all possible that your operating system is just cleaning up the python program? Being unresponsive for a minute at a time may give that impression... – Tadhg McDonald-Jensen Jun 08 '16 at 23:17

0 Answers0