From abd2e978a023fcc204f59c88f15e7a198cfbb588 Mon Sep 17 00:00:00 2001 From: ougongchang Date: Fri, 5 Mar 2021 16:57:43 +0800 Subject: [PATCH] Prevents child processes from entering sleep stat Note: When using sys.exit method, it is found that when the main process is killed, the summary process enters a sleep state and cannot execute the exit operation --- mindspore/train/summary/_writer_pool.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mindspore/train/summary/_writer_pool.py b/mindspore/train/summary/_writer_pool.py index 84602738d4..ec11b86351 100644 --- a/mindspore/train/summary/_writer_pool.py +++ b/mindspore/train/summary/_writer_pool.py @@ -14,7 +14,6 @@ # ============================================================================ """Write events to disk in a base directory.""" import os -import sys import time import signal from collections import deque @@ -101,7 +100,9 @@ class WriterPool(ctx.Process): with ctx.Pool(min(ctx.cpu_count(), 32)) as pool: deq = deque() while True: - self._check_heartbeat() + if self._check_heartbeat(): + self._close() + return while deq and deq[0].ready(): for plugin, data in deq.popleft().get(): @@ -195,6 +196,4 @@ class WriterPool(ctx.Process): "so SummaryRecord will not record data.") is_exit = True - if is_exit: - self._close() - sys.exit(1) + return is_exit