Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5435

Re: connect SIGINT to custom interrupt handler

From Nobody <nobody@nowhere.com>
Subject Re: connect SIGINT to custom interrupt handler
Date 2011-05-15 14:08 +0100
Message-Id <pan.2011.05.15.13.08.22.15000@nowhere.com>
Newsgroups comp.lang.python
References <slrnisv835.b74.chris@scheingraber.no-ip.org>
Organization Zen Internet

Show all headers | View raw


On Sun, 15 May 2011 09:44:04 +0000, Christoph Scheingraber wrote:

> signal.signal(signal.SIGINT, interrupt_handler)

> This worked fine in some rare lucky cases, but most of the times, the
> module I am using (my university's seismology project) catches the SIGINT
> and quits:
> 
> select.error: (4, 'Interrupted system call')

After installing the signal handler, call:

	signal.siginterrupt(signal.SIGINT, False)

This will cause (most) interrupted system calls to be restarted after the
signal has been handled.

> How can I prevent the imported module's function from catching the
> interrupt signal?

It isn't catching the signal. Unless you enable restarting of system
calls, an interrupted system call will typically fail with EINTR. Python
typically reports failures via exceptions; failures due to EINTR aren't
handled differently.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

connect SIGINT to custom interrupt handler Christoph Scheingraber <chris@spam.org> - 2011-05-15 09:44 +0000
  Re: connect SIGINT to custom interrupt handler Christoph Scheingraber <chris@spam.org> - 2011-05-15 14:32 +0000
    Re: connect SIGINT to custom interrupt handler Chris Angelico <rosuav@gmail.com> - 2011-05-16 01:30 +1000
    Re: connect SIGINT to custom interrupt handler Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-15 17:43 +0200
      Re: connect SIGINT to custom interrupt handler Christoph Scheingraber <spam@scheingraber.net> - 2011-05-15 17:05 +0000
        Re: connect SIGINT to custom interrupt handler Nobody <nobody@nowhere.com> - 2011-05-16 03:28 +0100
        Re: connect SIGINT to custom interrupt handler Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-05-20 09:38 +0200
    Re: connect SIGINT to custom interrupt handler Nobody <nobody@nowhere.com> - 2011-05-16 03:53 +0100
  Re: connect SIGINT to custom interrupt handler Nobody <nobody@nowhere.com> - 2011-05-15 14:08 +0100

csiph-web