From e4d3ed27ae630636a148013ca5b55ad06ecce7a3 Mon Sep 17 00:00:00 2001 From: "abarth@webkit.org" Date: Thu, 9 Feb 2012 00:27:36 +0000 Subject: [PATCH] webkitpy should reply upon the multiprocessing package existing https://bugs.webkit.org/show_bug.cgi?id=78176 Reviewed by Eric Seidel. Now that we don't support Python 2.5, this import can't fail. * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py: (get): (_Process): (_Process.__init__): (_Process.run): * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py: (FunctionTests.test_get__processes): (MultiProcessBrokerTests.setUp): * Scripts/webkitpy/layout_tests/port/base.py: (Port.__init__): (Port.default_worker_model): * Scripts/webkitpy/layout_tests/port/chromium_mac.py: (ChromiumMacPort.check_build): * Scripts/webkitpy/layout_tests/port/port_testcase.py: (PortTestCase.test_default_worker_model): * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107151 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 26 ++++++++ .../controllers/manager_worker_broker.py | 76 ++++++++++------------ .../controllers/manager_worker_broker_unittest.py | 18 +---- Tools/Scripts/webkitpy/layout_tests/port/base.py | 13 +--- .../webkitpy/layout_tests/port/chromium_mac.py | 7 -- .../webkitpy/layout_tests/port/port_testcase.py | 13 +--- .../run_webkit_tests_integrationtest.py | 7 +- 7 files changed, 65 insertions(+), 95 deletions(-) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 73e5e21..d0f2672 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,29 @@ +2012-02-08 Adam Barth + + webkitpy should reply upon the multiprocessing package existing + https://bugs.webkit.org/show_bug.cgi?id=78176 + + Reviewed by Eric Seidel. + + Now that we don't support Python 2.5, this import can't fail. + + * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py: + (get): + (_Process): + (_Process.__init__): + (_Process.run): + * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py: + (FunctionTests.test_get__processes): + (MultiProcessBrokerTests.setUp): + * Scripts/webkitpy/layout_tests/port/base.py: + (Port.__init__): + (Port.default_worker_model): + * Scripts/webkitpy/layout_tests/port/chromium_mac.py: + (ChromiumMacPort.check_build): + * Scripts/webkitpy/layout_tests/port/port_testcase.py: + (PortTestCase.test_default_worker_model): + * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py: + 2012-02-08 Gustavo Noronha Silva Unreviewed typo fix that makes docs build again for the gtk2-based diff --git a/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py b/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py index 82ba91f..34136ff 100755 --- a/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py +++ b/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py @@ -42,17 +42,11 @@ They interact more or less like: """ import logging +import multiprocessing import optparse import Queue import sys - -# Handle Python < 2.6 where multiprocessing isn't available. -try: - import multiprocessing -except ImportError: - multiprocessing = None - # These are needed when workers are launched in new child processes. from webkitpy.common.host import Host from webkitpy.common.host_mock import MockHost @@ -99,7 +93,7 @@ def get(port, options, client, worker_class): if worker_model == 'inline': queue_class = Queue.Queue manager_class = _InlineManager - elif worker_model == 'processes' and multiprocessing: + elif worker_model == 'processes': queue_class = multiprocessing.Queue manager_class = _MultiProcessManager else: @@ -245,40 +239,38 @@ class _InlineWorkerConnection(_WorkerConnection): raise exc_info[0], exc_info[1], exc_info[2] -if multiprocessing: - - class _Process(multiprocessing.Process): - def __init__(self, worker_connection, platform_name, options, client): - multiprocessing.Process.__init__(self) - self._worker_connection = worker_connection - self._platform_name = platform_name - self._options = options - self._client = client - - def run(self): - # We need to create a new Host object here because this is - # running in a new process and we can't require the parent's - # Host to be pickleable and passed to the child. - if self._platform_name.startswith('test'): - host = MockHost() - else: - host = Host() - host._initialize_scm() - - options = self._options - port_obj = host.port_factory.get(self._platform_name, options) - - # The unix multiprocessing implementation clones the - # log handler configuration into the child processes, - # but the win implementation doesn't. - configure_logging = (sys.platform == 'win32') - - # FIXME: this won't work if the calling process is logging - # somewhere other than sys.stderr and sys.stdout, but I'm not sure - # if this will be an issue in practice. - printer = printing.Printer(port_obj, options, sys.stderr, sys.stdout, configure_logging) - self._client.run(port_obj) - printer.cleanup() +class _Process(multiprocessing.Process): + def __init__(self, worker_connection, platform_name, options, client): + multiprocessing.Process.__init__(self) + self._worker_connection = worker_connection + self._platform_name = platform_name + self._options = options + self._client = client + + def run(self): + # We need to create a new Host object here because this is + # running in a new process and we can't require the parent's + # Host to be pickleable and passed to the child. + if self._platform_name.startswith('test'): + host = MockHost() + else: + host = Host() + host._initialize_scm() + + options = self._options + port_obj = host.port_factory.get(self._platform_name, options) + + # The unix multiprocessing implementation clones the + # log handler configuration into the child processes, + # but the win implementation doesn't. + configure_logging = (sys.platform == 'win32') + + # FIXME: this won't work if the calling process is logging + # somewhere other than sys.stderr and sys.stdout, but I'm not sure + # if this will be an issue in practice. + printer = printing.Printer(port_obj, options, sys.stderr, sys.stdout, configure_logging) + self._client.run(port_obj) + printer.cleanup() class _MultiProcessWorkerConnection(_WorkerConnection): diff --git a/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py b/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py index 8e63f93..e41e22c 100644 --- a/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py +++ b/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py @@ -31,15 +31,8 @@ import Queue import sys import unittest -try: - import multiprocessing -except ImportError: - multiprocessing = None - - from webkitpy.common.system import outputcapture from webkitpy.common.host_mock import MockHost - from webkitpy.layout_tests import port from webkitpy.layout_tests.controllers import manager_worker_broker from webkitpy.layout_tests.controllers import message_broker @@ -127,11 +120,7 @@ class FunctionTests(unittest.TestCase): # This test sometimes fails on Windows. See . if sys.platform in ('cygwin', 'win32'): return - - if multiprocessing: - self.assertTrue(make_broker(self, 'processes') is not None) - else: - self.assertRaises(ValueError, make_broker, self, 'processes') + self.assertTrue(make_broker(self, 'processes') is not None) def test_get__unknown(self): self.assertRaises(ValueError, make_broker, self, 'unknown') @@ -205,16 +194,13 @@ class _TestsMixin(object): # FIXME: https://bugs.webkit.org/show_bug.cgi?id=54520. -if multiprocessing and sys.platform not in ('cygwin', 'win32'): +if sys.platform not in ('cygwin', 'win32'): class MultiProcessBrokerTests(_TestsMixin, unittest.TestCase): def setUp(self): _TestsMixin.setUp(self) self._worker_model = 'processes' - def queue(self): - return multiprocessing.Queue() - class FunctionsTest(unittest.TestCase): def test_runtime_options(self): diff --git a/Tools/Scripts/webkitpy/layout_tests/port/base.py b/Tools/Scripts/webkitpy/layout_tests/port/base.py index ba2c382..10e2a82 100755 --- a/Tools/Scripts/webkitpy/layout_tests/port/base.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/base.py @@ -38,14 +38,6 @@ import re from webkitpy.common.memoized import memoized from webkitpy.common.system import path - - -# Handle Python < 2.6 where multiprocessing isn't available. -try: - import multiprocessing -except ImportError: - multiprocessing = None - from webkitpy.common import find_files from webkitpy.common.system import logutils from webkitpy.common.system.executive import ScriptError @@ -148,7 +140,6 @@ class Port(object): self.set_option_default('configuration', self.default_configuration()) self._test_configuration = None self._reftest_list = {} - self._multiprocessing_is_available = (multiprocessing is not None) self._results_directory = None def wdiff_available(self): @@ -176,9 +167,7 @@ class Port(object): return cpu_count def default_worker_model(self): - if self._multiprocessing_is_available: - return 'processes' - return 'inline' + return 'processes' def baseline_path(self): """Return the absolute path to the directory to store new baselines in for this port.""" diff --git a/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py b/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py index e6d557f..30f4aa9 100644 --- a/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py @@ -102,13 +102,6 @@ class ChromiumMacPort(chromium.ChromiumPort): return result - def default_child_processes(self): - if not self._multiprocessing_is_available: - # Running multiple threads in Mac Python is unstable (See - # https://bugs.webkit.org/show_bug.cgi?id=38553 for more info). - return 1 - return chromium.ChromiumPort.default_child_processes(self) - def operating_system(self): return 'mac' diff --git a/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py b/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py index 38b54fe..8df039c 100755 --- a/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py @@ -30,19 +30,11 @@ import errno import socket - import sys import time import unittest -# Handle Python < 2.6 where multiprocessing isn't available. -try: - import multiprocessing -except ImportError: - multiprocessing = None - from webkitpy.layout_tests.servers import http_server_base - from webkitpy.common.system.filesystem_mock import MockFileSystem from webkitpy.tool.mocktool import MockOptions from webkitpy.common.system.executive_mock import MockExecutive @@ -68,10 +60,7 @@ class PortTestCase(unittest.TestCase): def test_default_worker_model(self): port = self.make_port() - if multiprocessing: - self.assertEqual(port.default_worker_model(), 'processes') - else: - self.assertEqual(port.default_worker_model(), 'inline') + self.assertEqual(port.default_worker_model(), 'processes') def test_driver_cmd_line(self): port = self.make_port() diff --git a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py index 3f31e6b..ac9f8bb 100755 --- a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py +++ b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py @@ -43,14 +43,9 @@ import unittest from webkitpy.common.system import path -try: - import multiprocessing -except ImportError: - multiprocessing = None - # FIXME: remove this when we fix test-webkitpy to work properly on cygwin # (bug 63846). -SHOULD_TEST_PROCESSES = multiprocessing and sys.platform not in ('cygwin', 'win32') +SHOULD_TEST_PROCESSES = sys.platform not in ('cygwin', 'win32') from webkitpy.common import array_stream from webkitpy.common.system import outputcapture -- 2.7.4