Title: [115452] trunk/Tools
Revision
115452
Author
[email protected]
Date
2012-04-27 11:12:09 -0700 (Fri, 27 Apr 2012)

Log Message

webkitpy: fix race in unit tests for manager_worker_broker
https://bugs.webkit.org/show_bug.cgi?id=84925

Reviewed by Ojan Vafai.

I have been intermittently seeing hangs when running
test-webkitpy on Mac SL; it appears that there's a bug (?) in
the multiprocessing module where queue references are getting
leaked or not cleaned up somehow. By explicitly closing the
queues, things seem to be happy, so this patch adds a cleanup()
method to the message broker and modifies the manager (and the
unit tests) to call it. This may get rid of the intermittent
error on shutdown on Linux I've seen as well.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager._run_tests):
* Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py:
(_Broker.__del__):
(_Broker):
(_Broker.cleanup):
(_BrokerConnection.cleanup):
* Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py:
(_TestsMixin.test_name):
(_TestsMixin.test_cancel):
(_TestsMixin.test_done):
(_TestsMixin.test_unknown_message):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (115451 => 115452)


--- trunk/Tools/ChangeLog	2012-04-27 18:05:58 UTC (rev 115451)
+++ trunk/Tools/ChangeLog	2012-04-27 18:12:09 UTC (rev 115452)
@@ -1,3 +1,32 @@
+2012-04-27  Dirk Pranke  <[email protected]>
+
+        webkitpy: fix race in unit tests for manager_worker_broker
+        https://bugs.webkit.org/show_bug.cgi?id=84925
+
+        Reviewed by Ojan Vafai.
+
+        I have been intermittently seeing hangs when running
+        test-webkitpy on Mac SL; it appears that there's a bug (?) in
+        the multiprocessing module where queue references are getting
+        leaked or not cleaned up somehow. By explicitly closing the
+        queues, things seem to be happy, so this patch adds a cleanup()
+        method to the message broker and modifies the manager (and the
+        unit tests) to call it. This may get rid of the intermittent
+        error on shutdown on Linux I've seen as well.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager._run_tests):
+        * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py:
+        (_Broker.__del__):
+        (_Broker):
+        (_Broker.cleanup):
+        (_BrokerConnection.cleanup):
+        * Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py:
+        (_TestsMixin.test_name):
+        (_TestsMixin.test_cancel):
+        (_TestsMixin.test_done):
+        (_TestsMixin.test_unknown_message):
+
 2012-04-27  Gavin Peters  <[email protected]>
 
         Add new ENABLE_LINK_PRERENDER define to control the Prerendering API

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (115451 => 115452)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-04-27 18:05:58 UTC (rev 115451)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2012-04-27 18:12:09 UTC (rev 115452)
@@ -816,6 +816,7 @@
             self.cancel_workers()
             raise
         finally:
+            manager_connection.cleanup()
             self.stop_servers_with_lock()
 
         thread_timings = [worker_state.stats for worker_state in self._worker_states.values()]

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py (115451 => 115452)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py	2012-04-27 18:05:58 UTC (rev 115451)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker.py	2012-04-27 18:12:09 UTC (rev 115452)
@@ -143,6 +143,15 @@
         self._queue_maker = queue_maker
         self._topics = {}
 
+    def __del__(self):
+        self.cleanup()
+
+    def cleanup(self):
+        for queue in self._topics.values():
+            if hasattr(queue, 'close'):
+                queue.close()
+        self._topics = {}
+
     def add_topic(self, topic_name):
         if topic_name not in self._topics:
             self._topics[topic_name] = self._queue_maker()
@@ -226,6 +235,10 @@
         broker.add_topic(run_topic)
         broker.add_topic(post_topic)
 
+    def cleanup(self):
+        self._broker.cleanup()
+        self._broker = None
+
     def run_message_loop(self, delay_secs=None):
         self._broker.run_message_loop(self._run_topic, self._client, delay_secs)
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py (115451 => 115452)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py	2012-04-27 18:05:58 UTC (rev 115451)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_worker_broker_unittest.py	2012-04-27 18:12:09 UTC (rev 115452)
@@ -136,14 +136,16 @@
         worker.cancel()
         worker.join(0.1)
         self.assertFalse(worker.is_alive())
+        self._broker.cleanup()
 
     def test_cancel(self):
         self.make_broker()
         worker = self._broker.start_worker()
+        self._broker.post_message('test', 1, 'hello, world')
         worker.cancel()
-        self._broker.post_message('test', 1, 'hello, world')
         worker.join(0.1)
         self.assertFalse(worker.is_alive())
+        self._broker.cleanup()
 
     def test_done(self):
         self.make_broker()
@@ -156,6 +158,7 @@
         self.assertTrue(self.is_done())
         self.assertEqual(self._an_int, 2)
         self.assertEqual(self._a_str, 'hi, everybody')
+        self._broker.cleanup()
 
     def test_unknown_message(self):
         self.make_broker()
@@ -170,6 +173,7 @@
         finally:
             worker.join(0.5)
         self.assertFalse(worker.is_alive())
+        self._broker.cleanup()
 
 
 class InlineBrokerTests(_TestsMixin, unittest.TestCase):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to