未验证 提交 0ebb57de 编写于 作者: B Bo Zhou 提交者: GitHub

comiit (#392)

上级 78417815
...@@ -171,22 +171,28 @@ def start_master(port, cpu_num, monitor_port, debug, log_server_port_range): ...@@ -171,22 +171,28 @@ def start_master(port, cpu_num, monitor_port, debug, log_server_port_range):
# Redirect the output to DEVNULL to solve the warning log. # Redirect the output to DEVNULL to solve the warning log.
_ = subprocess.Popen( _ = subprocess.Popen(
master_command, stdout=FNULL, stderr=subprocess.STDOUT) master_command, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True)
if cpu_num > 0: if cpu_num > 0:
# Sleep 1s for master ready # Sleep 1s for master ready
time.sleep(1) time.sleep(1)
_ = subprocess.Popen( _ = subprocess.Popen(
worker_command, stdout=FNULL, stderr=subprocess.STDOUT) worker_command,
stdout=FNULL,
stderr=subprocess.STDOUT,
close_fds=True)
if _IS_WINDOWS: if _IS_WINDOWS:
# TODO(@zenghsh3) redirecting stdout of monitor subprocess to FNULL will cause occasional failure # TODO(@zenghsh3) redirecting stdout of monitor subprocess to FNULL will cause occasional failure
tmp_file = tempfile.TemporaryFile() tmp_file = tempfile.TemporaryFile()
_ = subprocess.Popen(monitor_command, stdout=tmp_file) _ = subprocess.Popen(monitor_command, stdout=tmp_file, close_fds=True)
tmp_file.close() tmp_file.close()
else: else:
_ = subprocess.Popen( _ = subprocess.Popen(
monitor_command, stdout=FNULL, stderr=subprocess.STDOUT) monitor_command,
stdout=FNULL,
stderr=subprocess.STDOUT,
close_fds=True)
FNULL.close() FNULL.close()
if cpu_num > 0: if cpu_num > 0:
...@@ -285,7 +291,7 @@ def start_worker(address, cpu_num, log_server_port_range): ...@@ -285,7 +291,7 @@ def start_worker(address, cpu_num, log_server_port_range):
str(cpu_num), "--log_server_port", str(cpu_num), "--log_server_port",
str(log_server_port) str(log_server_port)
] ]
p = subprocess.Popen(command) p = subprocess.Popen(command, close_fds=True)
if not is_log_server_started(get_ip_address(), log_server_port): if not is_log_server_started(get_ip_address(), log_server_port):
click.echo("# Fail to start the log server.") click.echo("# Fail to start the log server.")
......
...@@ -138,10 +138,7 @@ class TestLogServer(unittest.TestCase): ...@@ -138,10 +138,7 @@ class TestLogServer(unittest.TestCase):
else: else:
FNULL = open(os.devnull, 'w') FNULL = open(os.devnull, 'w')
monitor_proc = subprocess.Popen( monitor_proc = subprocess.Popen(
command, command, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True)
stdout=FNULL,
stderr=subprocess.STDOUT,
)
# Start worker # Start worker
cluster_addr = 'localhost:{}'.format(master_port) cluster_addr = 'localhost:{}'.format(master_port)
......
...@@ -69,7 +69,7 @@ class TestJob(unittest.TestCase): ...@@ -69,7 +69,7 @@ class TestJob(unittest.TestCase):
file_path = __file__.replace('reset_job_test', 'simulate_client') file_path = __file__.replace('reset_job_test', 'simulate_client')
command = [sys.executable, file_path] command = [sys.executable, file_path]
proc = subprocess.Popen(command) proc = subprocess.Popen(command, close_fds=True)
for _ in range(6): for _ in range(6):
if master.cpu_num == 0: if master.cpu_num == 0:
break break
......
...@@ -227,7 +227,11 @@ class Worker(object): ...@@ -227,7 +227,11 @@ class Worker(object):
# Redirect the output to DEVNULL # Redirect the output to DEVNULL
FNULL = open(os.devnull, 'w') FNULL = open(os.devnull, 'w')
for _ in range(job_num): for _ in range(job_num):
subprocess.Popen(command, stdout=FNULL, stderr=subprocess.STDOUT) subprocess.Popen(
command,
stdout=FNULL,
stderr=subprocess.STDOUT,
close_fds=True)
FNULL.close() FNULL.close()
new_jobs = [] new_jobs = []
...@@ -402,10 +406,7 @@ class Worker(object): ...@@ -402,10 +406,7 @@ class Worker(object):
else: else:
FNULL = open(os.devnull, 'w') FNULL = open(os.devnull, 'w')
log_server_proc = subprocess.Popen( log_server_proc = subprocess.Popen(
command, command, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True)
stdout=FNULL,
stderr=subprocess.STDOUT,
)
FNULL.close() FNULL.close()
log_server_address = "{}:{}".format(self.worker_ip, port) log_server_address = "{}:{}".format(self.worker_ip, port)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册