Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5415
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!news2.euro.net!newsfeed.freenet.ag!news.space.net!news.m-online.net!not-for-mail |
|---|---|
| From | Christoph Scheingraber <chris@spam.org> |
| Newsgroups | comp.lang.python |
| Subject | connect SIGINT to custom interrupt handler |
| Date | Sun, 15 May 2011 09:44:04 +0000 (UTC) |
| Organization | (posted via) M-net Telekommunikations GmbH |
| Lines | 39 |
| Message-ID | <slrnisv835.b74.chris@scheingraber.no-ip.org> (permalink) |
| Reply-To | usenet@scheingraber.net |
| NNTP-Posting-Host | ppp-188-174-17-224.dynamic.mnet-online.de |
| X-Trace | news.m-online.net 1305452644 5435 188.174.17.224 (15 May 2011 09:44:04 GMT) |
| X-Complaints-To | abuse@m-online.net |
| NNTP-Posting-Date | Sun, 15 May 2011 09:44:04 +0000 (UTC) |
| User-Agent | slrn/pre1.0.0-18 (Linux) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:5415 |
Show key headers only | View raw
Hi,
I am trying to connect SIGINT (^c) to a custom interrupt handler like
this (no threading, just straightforward):
if __name__ == "__main__":
quit = False
def interrupt_handler(signal, frame):
global quit
if not quit:
print "blabla, i'll finish my task and quit kind of message"
print "Press ^C again to interrupt immediately."
else:
sys.exit(2)
quit = True
signal.signal(signal.SIGINT, interrupt_handler)
# main will use the quit flag to determine if it should quit before next
# task
status = main()
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')
How can I prevent the imported module's function from catching the
interrupt signal?
Thanks to anyone that takes the time to help me...
Chris
--
Chris Scheingraber - www.scheingraber.net
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll 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