On Thu, Nov 24, 2011 at 5:07 PM, Steven D'Aprano
wrote:
>> 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.
Might be easiest to spin off a thread to do the work, and then have
the
On Thu, 24 Nov 2011 15:20:09 +1100, Chris Angelico wrote:
> On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano
> 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 w
On Thu, Nov 24, 2011 at 2:55 PM, Steven D'Aprano
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?
This looks like the classic "sigint handler s
I'm looking for a way to interrupt a long-running function on a key
press, but without halting the function.
E.g. if I have these two functions:
def handler(*args):
print "caught interrupt and continuing..."
def exercise_cpu():
for i in range(8):
print "working..."
for