From 87906f048e29476875db6485a0bbc64693ac37c6 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Mon, 22 Jul 2019 18:05:11 +0800 Subject: [PATCH] fix yolov3 subprocess not exit (#2886) * fix yolov3 subprocess not exit * refine print --- PaddleCV/yolov3/data_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PaddleCV/yolov3/data_utils.py b/PaddleCV/yolov3/data_utils.py index a0752efe..f5c52463 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): -- GitLab