diff --git a/PaddleCV/yolov3/data_utils.py b/PaddleCV/yolov3/data_utils.py index a0752efe46f3f76e7d645f2b8075e2fbcc9db752..f5c5246346a7ef4b568bbb3f3681793d36c22749 100644 --- a/PaddleCV/yolov3/data_utils.py +++ b/PaddleCV/yolov3/data_utils.py @@ -2,6 +2,7 @@ This code is based on https://github.com/fchollet/keras/blob/master/keras/utils/data_utils.py """ +import os import sys import signal import time @@ -19,7 +20,13 @@ def _reader_quit(signum, frame): print("Reader process exit.") sys.exit() +def _term_group(sig_num, frame): + print('pid {} terminated, terminate group ' + '{}...'.format(os.getpid(), os.getpgrp())) + os.killpg(os.getpgid(os.getpid()), signal.SIGKILL) + signal.signal(signal.SIGTERM, _reader_quit) +signal.signal(signal.SIGINT, _term_group) class GeneratorEnqueuer(object):