Python: wait for a key press or until timeout
<p>I have a long-running Python script inside a terminal session (the host machine is a FreeBSD box) that performs a task every 9 minutes. Now, I'd like to be able to interrupt that sleep call at any moment so that it performs the task right away.</p>

<p>How can I do that? Catching <kbd>Ctrl</kbd>+<kbd>C</kbd> is not an option as I need it to stop the program (rather than merely interrupting the sleep). Anything else that I can do with a terminal window and a keyboard is fine.</p>
