Merge pull request #4763 from blueyed/lsof

--lsof: suppress stderr
This commit is contained in:
Bruno Oliveira 2019-02-11 13:18:40 -02:00 committed by GitHub
commit 67dd10de26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -81,7 +81,11 @@ class LsofFdLeakChecker(object):
def _exec_lsof(self):
pid = os.getpid()
return subprocess.check_output(("lsof", "-Ffn0", "-p", str(pid))).decode()
# py3: use subprocess.DEVNULL directly.
with open(os.devnull, "wb") as devnull:
return subprocess.check_output(
("lsof", "-Ffn0", "-p", str(pid)), stderr=devnull
).decode()
def _parse_lsof_output(self, out):
def isopen(line):