Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Unified Diff: subprocess2.py

Issue 8750003: Add Popen.shell, add more subprocess2 tests and make it more compact. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rebase against HEAD Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/subprocess2_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: subprocess2.py
diff --git a/subprocess2.py b/subprocess2.py
index 99eebcc1ae89f8e47e8f73f0e6e43ca5c6cac3d5..c2f393a990004224f5329a03a74ca5bfd4f7ac86 100644
--- a/subprocess2.py
+++ b/subprocess2.py
@@ -17,6 +17,7 @@ import tempfile
import time
import threading
+
# Constants forwarded from subprocess.
PIPE = subprocess.PIPE
STDOUT = subprocess.STDOUT
@@ -182,8 +183,10 @@ class Popen(subprocess.Popen):
fix('stderr')
self.start = time.time()
+ self.shell = kwargs.get('shell', None)
# Silence pylint on MacOSX
self.returncode = None
+
try:
super(Popen, self).__init__(args, **kwargs)
except OSError, e:
@@ -238,6 +241,10 @@ def communicate(args, timeout=None, **kwargs):
with tempfile.TemporaryFile() as buff:
kwargs['stdout'] = buff
proc = Popen(args, **kwargs)
+ if proc.shell:
+ raise TypeError(
+ 'Using timeout and shell simultaneously will cause a process leak '
+ 'since the shell will be killed instead of the child process.')
if stdin is not None:
proc.stdin.write(stdin)
while proc.returncode is None:
« no previous file with comments | « no previous file | tests/subprocess2_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698