En Fri, 29 Jan 2010 14:39:31 -0300, MRAB <pyt...@mrabarnett.plus.com> escribió:
JohnnyFive wrote:

 My app is purely console based. I just don't want the console to lock
up (on Windows using time.sleep(x) causes the console to become
unresponsive until the timer is done), and I want people to be able to
CTRL+C to stop the script if need be (which can't be done if it's
unresponsive!).
 Thanks.

Which version of Python are you using? time.sleep(x) can be interrupted
in Python 2.6.

I'm able to be more precise: time.sleep() can be interrupted in any Python version since 2.3.

To the OP: beware of any unqualified 'except' clauses; a block like this:

  try:
    ...
  except:
    do_something_or_pass

may "swallow" the KeyboardInterrupt exception (generated by a Ctrl-C press). From Python 2.5 and up, the most generic exception clause should read `except Exception: ...` In previous versions, you had to explicitely re-raise KeyboardInterrupt and SystemExit in any catch-all block:

  try:
    ...
  except (KeyboardInterrupt, SystemExit):
    raise
  except:
    ...

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to