Skip to content
This repository was archived by the owner on Dec 19, 2017. It is now read-only.

Commit 1b674c7

Browse files
committed
1 parent f17a17b commit 1b674c7

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎lib/NP_pyfits.py‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from numpy import memmap as Memmap
4848
from string import maketrans
4949
import types
50+
import signal
5051

5152
# Module variables
5253
_blockLen = 2880 # the FITS block size
@@ -61,8 +62,7 @@
6162
ASCIITNULL = 0 # value for ASCII table cell with value = TNULL
6263
# this can be reset by user.
6364
_isInt = "isinstance(val, (int, long, np.integer))"
64-
65-
65+
6666
# Functions
6767

6868
def _padLength(stringLen):
@@ -4554,6 +4554,15 @@ def flush(self, output_verify='exception', verbose=0):
45544554
verbose: print out verbose messages? default = 0.
45554555
"""
45564556

4557+
# Define new signal interput handler
4558+
keyboardInterruptSent = False
4559+
def New_SIGINT(*args):
4560+
print "KeyboardInterrupt ignored until flush is complete!"
4561+
keyboardInterrputSent = True
4562+
4563+
# Install new handler
4564+
signal.signal(signal.SIGINT,New_SIGINT)
4565+
45574566
if self.__file.mode not in ('append', 'update'):
45584567
print "flush for '%s' mode is not supported." % self.__file.mode
45594568
return
@@ -4656,6 +4665,11 @@ def flush(self, output_verify='exception', verbose=0):
46564665
for hdu in self:
46574666
hdu.header._mod = 0
46584667
hdu.header.ascard._mod = 0
4668+
4669+
if keyboardInterruptSent:
4670+
raise KeyboardInterrupt
4671+
4672+
signal.signal(signal.SIGINT,signal.getsignal(signal.SIGINT))
46594673

46604674
def update_extend(self):
46614675
"""Make sure if the primary header needs the keyword EXTEND or if

0 commit comments

Comments
 (0)