提交 70462dae 编写于 作者: W wenkai

use forkserver multiprocess context to avoid forking child process with locked...

use forkserver multiprocess context to avoid forking child process with locked stream resource(eg stdout)
上级 a589d02c
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import fractions import fractions
import math import math
import threading import threading
import multiprocessing
from concurrent import futures from concurrent import futures
from mindinsight.utils.log import utils_logger as logger from mindinsight.utils.log import utils_logger as logger
...@@ -23,6 +24,9 @@ from mindinsight.utils.constant import GeneralErrors ...@@ -23,6 +24,9 @@ from mindinsight.utils.constant import GeneralErrors
from mindinsight.utils.exceptions import MindInsightException from mindinsight.utils.exceptions import MindInsightException
_MP_CONTEXT = multiprocessing.get_context(method="forkserver")
class ComputingResourceManager: class ComputingResourceManager:
""" """
Manager for computing resources. Manager for computing resources.
...@@ -44,7 +48,7 @@ class ComputingResourceManager: ...@@ -44,7 +48,7 @@ class ComputingResourceManager:
for ind in range(self._executors_cnt) for ind in range(self._executors_cnt)
} }
self._remaining_executors = len(self._executors) self._remaining_executors = len(self._executors)
self._backend = futures.ProcessPoolExecutor(max_workers=max_processes_cnt) self._backend = futures.ProcessPoolExecutor(max_workers=max_processes_cnt, mp_context=_MP_CONTEXT)
logger.info("Initialized ComputingResourceManager with executors_cnt=%s, max_processes_cnt=%s.", logger.info("Initialized ComputingResourceManager with executors_cnt=%s, max_processes_cnt=%s.",
executors_cnt, max_processes_cnt) executors_cnt, max_processes_cnt)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册