You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:59:34 UTC
[buildstream] 01/01: Stop repeatedly re-opening /dev/null
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch nanonyme/subprocess-devnull
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 7dc409c3be5037d7ff024a12539ca86f8a9d0653
Author: Seppo Yli-Olli <se...@gmail.com>
AuthorDate: Thu Dec 3 21:15:29 2020 +0200
Stop repeatedly re-opening /dev/null
---
buildstream/plugin.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/buildstream/plugin.py b/buildstream/plugin.py
index f278534..cc7788c 100644
--- a/buildstream/plugin.py
+++ b/buildstream/plugin.py
@@ -729,8 +729,7 @@ class Plugin():
def _output_file(self):
log = self.__context.get_log_handle()
if log is None:
- with open(os.devnull, "w") as output:
- yield output
+ yield subprocess.DEVNULL
else:
yield log
@@ -806,8 +805,9 @@ class Plugin():
if 'cwd' in kwargs:
workdir = kwargs['cwd']
command = " ".join(popenargs[0])
- output.write('Running host command {}: {}\n'.format(workdir, command))
- output.flush()
+ if output is not subprocess.DEVNULL:
+ output.write('Running host command {}: {}\n'.format(workdir, command))
+ output.flush()
self.status('Running host command', detail=command)
def _get_full_name(self):