mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-11 16:57:00 +02:00
Disable KeyboardInterrupt, just exit on SIGINT.
The KeyboardInterrupt exception doesn't get raised if the script is stuck in a blocking call, i.e., inside the check_event function. So pressing CTRL+C has no effect. This patch disables the exception, reverting to the OS' default behaviour for the SIGINT signal (i.e., terminate the program).
This commit is contained in:
parent
b323952e63
commit
d07bddc153
15
pgloader.py
15
pgloader.py
@ -663,7 +663,6 @@ def load_data():
|
|||||||
started = {}
|
started = {}
|
||||||
finished = {}
|
finished = {}
|
||||||
current = 0
|
current = 0
|
||||||
interrupted = False
|
|
||||||
|
|
||||||
max_running = MAX_PARALLEL_SECTIONS
|
max_running = MAX_PARALLEL_SECTIONS
|
||||||
if max_running == -1:
|
if max_running == -1:
|
||||||
@ -734,11 +733,6 @@ def load_data():
|
|||||||
log.error("can't open '%s' with given input encoding '%s'" \
|
log.error("can't open '%s' with given input encoding '%s'" \
|
||||||
% (filename, input_encoding))
|
% (filename, input_encoding))
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
interrupted = True
|
|
||||||
log.warning("Aborting on user demand (Interrupt)")
|
|
||||||
break
|
|
||||||
|
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
# typically, No Space Left On Device, can't report nor continue
|
# typically, No Space Left On Device, can't report nor continue
|
||||||
break
|
break
|
||||||
@ -756,7 +750,7 @@ def load_data():
|
|||||||
td = time.time() - begin
|
td = time.time() - begin
|
||||||
retcode = 0
|
retcode = 0
|
||||||
|
|
||||||
if SUMMARY and not interrupted:
|
if SUMMARY:
|
||||||
try:
|
try:
|
||||||
retcode = print_summary(None, sections, summary, td)
|
retcode = print_summary(None, sections, summary, td)
|
||||||
print
|
print
|
||||||
@ -769,6 +763,9 @@ def load_data():
|
|||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Disable KeyboardInterrupt, just exit on CTRL+C
|
||||||
|
import signal, os
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
try:
|
try:
|
||||||
ret = load_data()
|
ret = load_data()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@ -782,9 +779,5 @@ if __name__ == "__main__":
|
|||||||
sys.stderr.write(str(e) + '\n')
|
sys.stderr.write(str(e) + '\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
except KeyboardInterrupt, e:
|
|
||||||
sys.stderr.write(str(e) + '\n')
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user