Skip to content
Permalink
Browse files
2010-03-01 Dirk Pranke <dpranke@chromium.org>
        Reviewed by Eric Seidel.

        Work around a bug in Python's subprocess.Popen() that keeps us from
        cleaning up DumpRenderTree / test_shell properly when we finish the
        tests in new-run-webkit-tests.

        https://bugs.webkit.org/show_bug.cgi?id=35553

        * Scripts/webkitpy/layout_tests/port/chromium.py:
        * Scripts/webkitpy/layout_tests/port/mac.py:

Canonical link: https://commits.webkit.org/46689@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55388 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
dpranke committed Mar 2, 2010
1 parent 07950d4 commit a3f0629bf08564b468fbc4dd2f7f0bdbef78c36a
Showing 3 changed files with 58 additions and 17 deletions.
@@ -1,3 +1,16 @@
2010-03-01 Dirk Pranke <dpranke@chromium.org>

Reviewed by Eric Seidel.

Work around a bug in Python's subprocess.Popen() that keeps us from
cleaning up DumpRenderTree / test_shell properly when we finish the
tests in new-run-webkit-tests.

https://bugs.webkit.org/show_bug.cgi?id=35553

* Scripts/webkitpy/layout_tests/port/chromium.py:
* Scripts/webkitpy/layout_tests/port/mac.py:

2010-03-01 Arno Renevier <arno@renevier.net>

Reviewed by Xan Lopez.
@@ -227,10 +227,14 @@ def __init__(self, port, image_path, options):
cmd += [port._path_to_driver(), '--layout-tests']
if options:
cmd += options

# We need to pass close_fds=True to work around Python bug #2320
# (otherwise we can hang when we kill test_shell when we are running
# multiple threads). See http://bugs.python.org/issue2320 .
self._proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)

stderr=subprocess.STDOUT,
close_fds=True)
def poll(self):
return self._proc.poll()

@@ -299,10 +303,20 @@ def stop(self):
self._proc.stdout.close()
if self._proc.stderr:
self._proc.stderr.close()
if (sys.platform not in ('win32', 'cygwin') and
not self._proc.poll()):
# Closing stdin/stdout/stderr hangs sometimes on OS X.
null = open(os.devnull, "w")
subprocess.Popen(["kill", "-9",
str(self._proc.pid)], stderr=null)
null.close()
if sys.platform not in ('win32', 'cygwin'):
# Closing stdin/stdout/stderr hangs sometimes on OS X,
# (see __init__(), above), and anyway we don't want to hang
# the harness if test_shell is buggy, so we wait a couple
# seconds to give test_shell a chance to clean up, but then
# force-kill the process if necessary.
KILL_TIMEOUT = 3.0
timeout = time.time() + KILL_TIMEOUT
while self._proc.poll() is None and time.time() < timeout:
time.sleep(0.1)
if self._proc.poll() is None:
logging.warning('stopping test driver timed out, '
'killing it')
null = open(os.devnull, "w")
subprocess.Popen(["kill", "-9",
str(self._proc.pid)], stderr=null)
null.close()
@@ -321,10 +321,14 @@ def poll(self):

def restart(self):
self.stop()
# We need to pass close_fds=True to work around Python bug #2320
# (otherwise we can hang when we kill test_shell when we are running
# multiple threads). See http://bugs.python.org/issue2320 .
self._proc = subprocess.Popen(self._cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=self._env)
env=self._env,
close_fds=True)

def returncode(self):
return self._proc.returncode
@@ -425,13 +429,23 @@ def stop(self):
self._proc.stdout.close()
if self._proc.stderr:
self._proc.stderr.close()
if (sys.platform not in ('win32', 'cygwin') and
not self._proc.poll()):
# Closing stdin/stdout/stderr hangs sometimes on OS X.
null = open(os.devnull, "w")
subprocess.Popen(["kill", "-9",
str(self._proc.pid)], stderr=null)
null.close()
if sys.platform not in ('win32', 'cygwin'):
# Closing stdin/stdout/stderr hangs sometimes on OS X,
# (see restart(), above), and anyway we don't want to hang
# the harness if test_shell is buggy, so we wait a couple
# seconds to give test_shell a chance to clean up, but then
# force-kill the process if necessary.
KILL_TIMEOUT = 3.0
timeout = time.time() + KILL_TIMEOUT
while self._proc.poll() is None and time.time() < timeout:
time.sleep(0.1)
if self._proc.poll() is None:
logging.warning('stopping test driver timed out, '
'killing it')
null = open(os.devnull, "w")
subprocess.Popen(["kill", "-9",
str(self._proc.pid)], stderr=null)
null.close() not self._proc.poll()):

def _read_line(self, timeout, stop_time, image_length=0):
now = time.time()

0 comments on commit a3f0629

Please sign in to comment.