Make tools/submit_try safer
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 16 Jan 2014 19:48:19 +0000 (19:48 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 16 Jan 2014 19:48:19 +0000 (19:48 +0000)
Using proc.wait() in combination with PIPE doesn't seem
to be safe for large patches according to
http://docs.python.org/2/library/subprocess.html.

Moving to proc.communicate().

Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
BUG=skia:
R=djsollen@google.com, borenet@google.com

Author: kevin.petit.arm@gmail.com

Review URL: https://codereview.chromium.org/141023003

git-svn-id: http://skia.googlecode.com/svn/trunk@13113 2bbb7eff-a529-9590-31e7-b0007b416f81

tools/submit_try

index e371afb..6647b89 100755 (executable)
@@ -286,15 +286,17 @@ def SubmitTryRequest(args, is_svn=True):
     cmd = [GIT, 'diff', git_cl.Changelist().GetUpstreamBranch(),
            '--no-ext-diff']
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    if proc.wait() != 0:
+    git_data = proc.communicate()
+    if git_data[0] is None:
       raise Exception('Failed to capture git diff!')
 
     temp_dir = tempfile.mkdtemp()
     try:
       diff_file = os.path.join(temp_dir, 'patch.diff')
       with open(diff_file, 'wb') as f:
-        f.write(proc.communicate()[0])
-  
+        f.write(git_data[0])
+        f.close()
+
       try_args = ['--use_svn',
                   '--svn_repo', GetTryRepo(),
                   '--root', GetCheckoutRoot(is_svn),