Skip to content

Commit

Permalink
kill process group when main process exit (PaddlePaddle#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
heavengate committed Feb 21, 2020
1 parent dbdbff1 commit 029a0ec
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ppdet/data/parallel_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import division
from __future__ import print_function

import os
import sys
import six
if six.PY3:
Expand Down Expand Up @@ -281,3 +282,13 @@ def reset(self):
# FIXME(dengkaipeng): fix me if you have better impliment
# handle terminate reader process, do not print stack frame
signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit())


def _term_group(sig_num, frame):
pid = os.getpid()
pg = os.getpgid(os.getpid())
logger.info("main proc {} exit, kill process group " "{}".format(pid, pg))
os.killpg(pg, signal.SIGKILL)


signal.signal(signal.SIGINT, _term_group)

0 comments on commit 029a0ec

Please sign in to comment.