Bind key press to call function
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Nov 24 01:07:47 EST 2011
On Thu, 24 Nov 2011 15:20:09 +1100, Chris Angelico wrote:
> On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> I'm looking for a way to interrupt a long-running function on a key
>> press, but without halting the function.
>
> I assume there's a reason for not using Ctrl-C and SIGINT with the
> signal module?
Yes, I want to leave Ctrl-C alone and have a similar, but separate,
signal handler (or equivalent).
> This looks like the classic "sigint handler sets a flag that the main
> loop polls" structure.
Exactly. I am open to alternative methods if they are lightweight.
--
Steven
More information about the Python-list
mailing list