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

Unified Diff: subprocess2.py

Issue 6759074: Reapply r79779: "Removed gclient_utils.Popen() and use subprocess2's version instead." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 months 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 | « gclient_utils.py ('k') | tests/gclient_utils_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 c9057ac6ae19dd32c996b6c333bd5cc071a21d84..d4fa5781d6ee1be9f99b14ab17c156f2b02f1260 100644
--- a/subprocess2.py
+++ b/subprocess2.py
@@ -8,6 +8,7 @@ In theory you shouldn't need anything else in subprocess, or this module failed.
"""
from __future__ import with_statement
+import errno
import logging
import os
import subprocess
@@ -124,7 +125,7 @@ def get_english_env(env):
def Popen(args, **kwargs):
- """Wraps subprocess.Popen().
+ """Wraps subprocess.Popen() with various workarounds.
Returns a subprocess.Popen object.
@@ -134,7 +135,8 @@ def Popen(args, **kwargs):
shell parameter to a value.
- Adds support for VOID to not buffer when not needed.
- Note: Popen() can throw OSError when cwd or args[0] doesn't exist.
+ Note: Popen() can throw OSError when cwd or args[0] doesn't exist. Translate
+ exceptions generated by cygwin when it fails trying to emulate fork().
"""
# Make sure we hack subprocess if necessary.
hack_subprocess()
@@ -160,7 +162,20 @@ def Popen(args, **kwargs):
kwargs['stdout'] = open(os.devnull, 'w')
if kwargs.get('stderr') in (VOID, os.devnull):
kwargs['stderr'] = open(os.devnull, 'w')
- return subprocess.Popen(args, **kwargs)
+ try:
+ return subprocess.Popen(args, **kwargs)
+ except OSError, e:
+ if e.errno == errno.EAGAIN and sys.platform == 'cygwin':
+ # Convert fork() emulation failure into a CalledProcessError().
+ raise CalledProcessError(
+ e.errno,
+ args,
+ kwargs.get('cwd'),
+ 'Visit '
+ 'http://code.google.com/p/chromium/wiki/CygwinDllRemappingFailure to '
+ 'learn how to fix this error; you need to rebase your cygwin dlls',
+ None)
+ raise
def call(args, timeout=None, **kwargs):
« no previous file with comments | « gclient_utils.py ('k') | tests/gclient_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698