Commit Graph

42 Commits (442fb64cab695a5fabec8ba32b1b733acd5b8ef8)

Author SHA1 Message Date
torne@chromium.org 434e79038d Work around race condition in subprocess.
There's a race condition in python's subprocess module, and gclient uses
it heavily while multithreaded. Avoid the race by locking around calls
to subprocess.Popen's constructor. Detailed explanation in the bug.

BUG=531561

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@296685 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
sbc@chromium.org 217330f2f0 Add quotes around command line in subproccess error message
Allows the command line itself to be distinguished
from the surrounding error message.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295481 0039d316-1c4b-4281-b951-d872f2087c98
10 years ago
tandrii@chromium.org c15fe57f12 Make check_output of subprocess2 compatible with Python's subprocess.
According to Python's doc (
https://docs.python.org/2/library/subprocess.html#subprocess.check_output
):
if check_output raises exception CalledProcessError, the exception object
should contain stdout data as `output` attribute. Before this commit,
subprocess2.CalledProcessError had `output` always None, and used `stdout`
instead. This commit fixes this problem storing the same data in both `stdout`
and `output`.

BUG=NONE

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@292036 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
pgervais@chromium.org fb653b65e5 More explicit error message
When running an executable fails, the original error message sent by
the OS is printed, together with a more detailed suggested solution.

BUG=

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@266908 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
pgervais@chromium.org 022d06ef61 git new-branch displays an explanatory line.
BUG=

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@266905 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
luqui@chromium.org 7f627a9130 Improve error message in subprocess2.py.
BUG=

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@260049 0039d316-1c4b-4281-b951-d872f2087c98
11 years ago
szager@chromium.org 12b07e7e55 Refactor nag functionality in to NagTimer class.
Add default 30 second nag timer to gclient subprocesses.

BUG=227537

Review URL: https://chromiumcodereview.appspot.com/14826003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@198207 0039d316-1c4b-4281-b951-d872f2087c98
12 years ago
szager@chromium.org e0558e6502 Add nag_timer.
BUG=227537
R=maruel@chromium.org,cmp@chromium.org
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/14798003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@197790 0039d316-1c4b-4281-b951-d872f2087c98
12 years ago
szager@chromium.org b054ebc8f3 Don't discard stderr.
R=maruel@chromium.org
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@197419 0039d316-1c4b-4281-b951-d872f2087c98
12 years ago
maruel@chromium.org cd8d8e1702 Correct invalid use of 'is' when '==' should have been used.
R=nsylvain@chromium.org
BUG=


Review URL: https://chromiumcodereview.appspot.com/11046016

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@159909 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org 4f6852cca4 Remove python 2.5 compatibility code.
R=cmp@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/10165007

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@133265 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org 740a6c0bd5 Using lists is faster than cStringIO.
Clean up stdin management.
Remove stale comments.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8808002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@113065 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org 94c712fa1b Reimplement r109239 but using Popen.communicate() instead.
Enables threaded callback handler for subprocess.communicate().

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8749015

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@112465 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org a8e8163a06 Add Popen.shell, add more subprocess2 tests and make it more compact.
R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8750003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@112351 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org 14e37ad7ad Silence pylint on Mac OSX 10.6
Also, increase the wait for socket binding to 0.2 seconds because OSX10.6 is
broken _and_ slow.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8749005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@112277 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org db59bfc139 Improve testing by comparing behavior of subprocess to subprocess2
This makes sure no regression relative to subprocess is introduced in
subprocess2.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8722001

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@112217 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org dd9837f9d9 Add Popen.start property.
R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8694006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@112102 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@google.com ef77f9e63a Make subprocess2.Popen a class instead of a function.
This will be necessary to override member functions eventually. It also better
replicates what subprocess.Popen is.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8570005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@111530 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org 4942e4a587 Add most of testing improvements without the tee-specific tests
Change return value from list to tuple for communicate(timeout != None).

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8539015

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@110094 0039d316-1c4b-4281-b951-d872f2087c98
13 years ago
maruel@chromium.org 7eda862b1f Revert r109283, r109282 and r109239.
"Add callback support for stdout and stderr."
"Add tests for both universal_newlines=True and False."
"Implement accelerated tee support for POSIX."

The reason is that the semantic of
subprocess2.check_call(cmd, timeout=60, stderr=subprocess2.STDOUT) changed,
stderr wasn't redirected to VOID anymore and for an unknown reason, it was
hanging until the timeout happened. Will reapply r109239 with a new regression
test to detect that bug.

TBR=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8505046

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@109369 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org fefff18b55 Implement accelerated tee support for POSIX.
This removes all the need of threading, which removes the contention on the GIL
lock.

Taking S2Test.test_check_output_tee_large as baseline, numbers are
real/user/sys in seconds:
Ubuntu workstation: ~25x  2.4/1.9/1.5 -> 0.10/0.70/0.02
OSX 10.6 laptop:    ~40x  6.4/5.3/3.9 -> 0.15/0.80/0.07
Cygwin on win7:      ~4x  2.8/2.2/1.3 -> 0.60/0.16/0.30

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8462008

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@109283 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 65be6f6bcf Add callback support for stdout and stderr.
It's currently an inefficient thread implementation. Interestingly
enough, callback support is significantly faster on cygwin than on
native python.

Writing an efficient implementation is punted for a later change,
one per implementation.

Stops using a temporary file since it's not necessary anymore.

The goal is to reduce the number of places where a similar paradigm
is used by having a canonical generic implementation.

R=dpranke@chromium.org
BUG=
TEST=Tested manually on Windows, cygwin, linux, OSX 10.6


Review URL: http://codereview.chromium.org/8374026

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@109239 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 5515655982 Fix subprocess2.Popen() logging when given a string
R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8361006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@106706 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 87e6d33103 Update subprocess2.check_output() to behave like subprocess.check_output().
stderr is not redirected by default. stdout is not allowed.
Both were oversight.
Do not override stdin=None in case the user would response to stderr output for
example.

Increase test coverage.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/7860041

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@100456 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 57bf78d82a Update docstrings w.r.t. subprocess2.
No code change.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/7858001

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@100212 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 0bcd1d3430 Make subprocess2.check_call() compliant with subprocess.check_call().
Rename check_call to check_call_out. It's a quite specific need when stderr is
needed or when the user doesn't want the default arguments of check_output.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6882127

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@83023 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 39f645ff57 Unicode input is also accepted for stdin.
R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6878069

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@82410 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 1f063db16a Make subprocess2.call() returned values to be the same as subprocess.call().
Renamed the previous subprocess2.call() to subprocess2.communicate().

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6877005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81976 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 0d5ef24c5d Use a marker instead of a string so it can be distingished when used as stdin.
R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6840053

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81941 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 4a982271a7 Defaults stdin to VOID for capture and check_output()
Since no output is user visible anyway, causing a hang with no clue about what
to type in.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6823091

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81302 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 1d9f62946b Set returncode to subprocess2.TIMED_OUT instead of -9 when a process times out.
R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6806009

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80775 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org c98c0c5249 Make more tests pass on Windows.
Also fix a few issues found along the way.

Tests had regressed a lot. Add a lot of tweaks to make most test pass.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6792060

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80618 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org f08b09c2af Fix automatic shell detection, the check was reversed
Improved tests and added regression test.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6793044

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80614 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org eba4022de8 Add subprocess2 unit tests
R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6693078

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80454 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 58ef297bc5 Revert r80216 "Reapply r79779: "Removed gclient_utils.Popen() and use subprocess2's ...""
Horked windows slaves this time.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6689023

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80220 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 93ef410768 Reapply r79779: "Removed gclient_utils.Popen() and use subprocess2's version instead."
It should be fine now that I've fixed python2.5 compatilibity issues in subprocess2.py.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6759074

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80216 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 421982fe08 Update docstrings and add VOID support
And update local_rietveld to use it.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6706022

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80179 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org fb3d3245ad Add subprocess.Popen().kill() to python 2.5.
Move code in tests/fake_repos.py to subprocess2.py.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6783022

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80152 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 45d8db04f9 Add more python 2.5 compatibility.
Makes all the tests runnable on python 2.5.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6690034

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@80068 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 5a376ed328 Revert r79779: "Removed gclient_utils.Popen() and use subprocess2's version instead."
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79781 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 242549409f Removed gclient_utils.Popen() and use subprocess2's version instead.
R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6770028

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79779 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago
maruel@chromium.org 4860f0527a Copy subprocess2 from commit-queue so it can be reused here.
A lot of functions in gclient_utils and elsewhere will be deleted.

Not used yet, committed as a separate change so it can be rubberstamped. :)

R=dpranke@chromium.org
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6711080

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79449 0039d316-1c4b-4281-b951-d872f2087c98
14 years ago