mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-11 08:46:59 +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 = {}
|
||||
finished = {}
|
||||
current = 0
|
||||
interrupted = False
|
||||
|
||||
max_running = MAX_PARALLEL_SECTIONS
|
||||
if max_running == -1:
|
||||
@ -734,11 +733,6 @@ def load_data():
|
||||
log.error("can't open '%s' with given input encoding '%s'" \
|
||||
% (filename, input_encoding))
|
||||
|
||||
except KeyboardInterrupt:
|
||||
interrupted = True
|
||||
log.warning("Aborting on user demand (Interrupt)")
|
||||
break
|
||||
|
||||
except IOError, e:
|
||||
# typically, No Space Left On Device, can't report nor continue
|
||||
break
|
||||
@ -756,7 +750,7 @@ def load_data():
|
||||
td = time.time() - begin
|
||||
retcode = 0
|
||||
|
||||
if SUMMARY and not interrupted:
|
||||
if SUMMARY:
|
||||
try:
|
||||
retcode = print_summary(None, sections, summary, td)
|
||||
print
|
||||
@ -769,6 +763,9 @@ def load_data():
|
||||
return retcode
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Disable KeyboardInterrupt, just exit on CTRL+C
|
||||
import signal, os
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
try:
|
||||
ret = load_data()
|
||||
except Exception, e:
|
||||
@ -782,9 +779,5 @@ if __name__ == "__main__":
|
||||
sys.stderr.write(str(e) + '\n')
|
||||
sys.exit(1)
|
||||
|
||||
except KeyboardInterrupt, e:
|
||||
sys.stderr.write(str(e) + '\n')
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(ret)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user