connect SIGINT to custom interrupt handler

Chris Angelico rosuav at gmail.com
Sun May 15 11:30:10 EDT 2011


On Mon, May 16, 2011 at 12:32 AM, Christoph Scheingraber <chris at spam.org> wrote:
> I now have signal.siginterrupt(signal.SIGINT, False) in the line
> below signal.signal(signal.SIGINT, interrupt_handler)
>
> Unfortunately, pressing ^c still results in the same interrupt error. I
> also tried putting signal.siginterrupt into the interrupt_handler
> function, which gave an interesting result:
>    File "/usr/local/bin/obspysod", line 586, in interrupt_handler
>    signal.siginterrupt(signal.SIGINT, False)
>    AttributeError: 'int' object has no attribute 'siginterrupt'
>
> Could there be a namespace problem?

def interrupt_handler(signal, frame):

You're using 'signal' as a parameter here. The local int is masking
the global module.

Chris Angelico



More information about the Python-list mailing list