From 876b695219f32e2684f24131bb3bd632e389c569 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 10 Feb 2024 23:21:15 +0900 Subject: [PATCH] Use built-in subprocess.DEVNULL ... instead of creating a file object. Change-Id: I6f61369f1770f8223544ec5040deeded7640b81b --- storlets/agent/daemon_factory/server.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/storlets/agent/daemon_factory/server.py b/storlets/agent/daemon_factory/server.py index 47a2ef66..296aaa51 100644 --- a/storlets/agent/daemon_factory/server.py +++ b/storlets/agent/daemon_factory/server.py @@ -130,15 +130,13 @@ class StorletDaemonFactory(SBusServer): self.logger.debug('Starting subprocess: pargs:{0} env:{1}' .format(str_pargs, env)) - # TODO(takashi): We had better use contextmanager - # TODO(takashi): Where is this closed? try: - dn = open(os.devnull, 'wb') daemon_p = subprocess.Popen( - pargs, stdout=dn, stderr=subprocess.PIPE, + pargs, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, close_fds=True, shell=False, env=env) logger_p = subprocess.Popen( - 'logger', stdin=daemon_p.stderr, stdout=dn, stderr=dn, + 'logger', stdin=daemon_p.stderr, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, close_fds=True, shell=False) except OSError: self.logger.exception('Unable to start subprocess')