mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Fix delegator leaky file handles
Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Vendored
+15
-6
@@ -178,6 +178,7 @@ class Command(object):
|
||||
# Use subprocess.
|
||||
if self.blocking:
|
||||
popen_kwargs = self._default_popen_kwargs.copy()
|
||||
del popen_kwargs["stdin"]
|
||||
popen_kwargs["universal_newlines"] = not binary
|
||||
if cwd:
|
||||
popen_kwargs["cwd"] = cwd
|
||||
@@ -234,14 +235,22 @@ class Command(object):
|
||||
"""Blocks until process is complete."""
|
||||
if self._uses_subprocess:
|
||||
# consume stdout and stderr
|
||||
try:
|
||||
stdout, stderr = self.subprocess.communicate()
|
||||
self.__out = stdout
|
||||
self.__err = stderr
|
||||
except ValueError:
|
||||
pass # Don't read from finished subprocesses.
|
||||
if self.blocking:
|
||||
try:
|
||||
stdout, stderr = self.subprocess.communicate()
|
||||
self.__out = stdout
|
||||
self.__err = stderr
|
||||
except ValueError:
|
||||
pass # Don't read from finished subprocesses.
|
||||
else:
|
||||
self.subprocess.stdin.close()
|
||||
self.std_out.close()
|
||||
self.std_err.close()
|
||||
self.subprocess.wait()
|
||||
else:
|
||||
self.subprocess.sendeof()
|
||||
self.subprocess.wait()
|
||||
self.subprocess.proc.stdout.close()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
"""Runs the current command and passes its output to the next
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
diff --git a/pipenv/vendor/delegator.py b/pipenv/vendor/delegator.py
|
||||
index 0c140cad..3ffb2e31 100644
|
||||
--- a/pipenv/vendor/delegator.py
|
||||
+++ b/pipenv/vendor/delegator.py
|
||||
@@ -178,6 +178,7 @@ class Command(object):
|
||||
# Use subprocess.
|
||||
if self.blocking:
|
||||
popen_kwargs = self._default_popen_kwargs.copy()
|
||||
+ del popen_kwargs["stdin"]
|
||||
popen_kwargs["universal_newlines"] = not binary
|
||||
if cwd:
|
||||
popen_kwargs["cwd"] = cwd
|
||||
@@ -233,18 +234,23 @@ class Command(object):
|
||||
def block(self):
|
||||
"""Blocks until process is complete."""
|
||||
if self._uses_subprocess:
|
||||
- self.subprocess.stdin.close()
|
||||
# consume stdout and stderr
|
||||
- try:
|
||||
- stdout, stderr = self.subprocess.communicate()
|
||||
- self.__out = stdout
|
||||
- self.__err = stderr
|
||||
- except ValueError:
|
||||
- pass # Don't read from finished subprocesses.
|
||||
+ if self.blocking:
|
||||
+ try:
|
||||
+ stdout, stderr = self.subprocess.communicate()
|
||||
+ self.__out = stdout
|
||||
+ self.__err = stderr
|
||||
+ except ValueError:
|
||||
+ pass # Don't read from finished subprocesses.
|
||||
+ else:
|
||||
+ self.subprocess.stdin.close()
|
||||
+ self.std_out.close()
|
||||
+ self.std_err.close()
|
||||
+ self.subprocess.wait()
|
||||
else:
|
||||
self.subprocess.sendeof()
|
||||
- self.subprocess.proc.stdout.close()
|
||||
self.subprocess.wait()
|
||||
+ self.subprocess.proc.stdout.close()
|
||||
|
||||
def pipe(self, command, timeout=None, cwd=None):
|
||||
"""Runs the current command and passes its output to the next
|
||||
Reference in New Issue
Block a user