<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[278624] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/278624">278624</a></dd>
<dt>Author</dt> <dd>Hironori.Fujii@sony.com</dd>
<dt>Date</dt> <dd>2021-06-08 12:58:00 -0700 (Tue, 08 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>run-webkit-tests: TaskPool reports PicklingError for Windows Python
https://bugs.webkit.org/show_bug.cgi?id=226710

Reviewed by Jonathan Bedard.

Since <a href="http://trac.webkit.org/projects/webkit/changeset/278454">r278454</a> changed run-webkit-tests to use TaskPool,
run-webkit-tests reported PicklingError for Windows Python. It
couldn't pickle Port object. This issue happened on multi-core PC,
but on single CPU tester bot machines.

WrappedPopen couldn't be pickled because it was defined as an
inner class. It should be defined at the top-level.

The instance variables _web_platform_test_server,
_websocket_server_temporary_directory, and
_websocket_secure_server of Port object aren't pickleable. Make
them class variables.

* Scripts/webkitpy/common/system/executive.py:
(WrappedPopen):
(Executive.WrappedPopen):
* Scripts/webkitpy/port/base.py:
(Port):
(Port.__init__):
(Port.ports_to_forward):
(Port.is_websocket_server_running):
(Port.is_wpt_server_running):
(Port.start_websocket_server):
(Port.start_web_platform_test_server):
(Port.stop_websocket_server):
(Port.stop_web_platform_test_server):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpycommonsystemexecutivepy">trunk/Tools/Scripts/webkitpy/common/system/executive.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportbasepy">trunk/Tools/Scripts/webkitpy/port/base.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (278623 => 278624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-06-08 19:16:17 UTC (rev 278623)
+++ trunk/Tools/ChangeLog       2021-06-08 19:58:00 UTC (rev 278624)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2021-06-08  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        run-webkit-tests: TaskPool reports PicklingError for Windows Python
+        https://bugs.webkit.org/show_bug.cgi?id=226710
+
+        Reviewed by Jonathan Bedard.
+
+        Since r278454 changed run-webkit-tests to use TaskPool,
+        run-webkit-tests reported PicklingError for Windows Python. It
+        couldn't pickle Port object. This issue happened on multi-core PC,
+        but on single CPU tester bot machines.
+
+        WrappedPopen couldn't be pickled because it was defined as an
+        inner class. It should be defined at the top-level.
+
+        The instance variables _web_platform_test_server,
+        _websocket_server_temporary_directory, and
+        _websocket_secure_server of Port object aren't pickleable. Make
+        them class variables.
+
+        * Scripts/webkitpy/common/system/executive.py:
+        (WrappedPopen):
+        (Executive.WrappedPopen):
+        * Scripts/webkitpy/port/base.py:
+        (Port):
+        (Port.__init__):
+        (Port.ports_to_forward):
+        (Port.is_websocket_server_running):
+        (Port.is_wpt_server_running):
+        (Port.start_websocket_server):
+        (Port.start_web_platform_test_server):
+        (Port.stop_websocket_server):
+        (Port.stop_web_platform_test_server):
+
</ins><span class="cx"> 2021-06-08  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Factor MarkedText collection out of LegacyInlineTextBox
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpycommonsystemexecutivepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/common/system/executive.py (278623 => 278624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/common/system/executive.py  2021-06-08 19:16:17 UTC (rev 278623)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive.py     2021-06-08 19:58:00 UTC (rev 278624)
</span><span class="lines">@@ -81,23 +81,24 @@
</span><span class="cx">         return os.path.basename(command_path)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class WrappedPopen(object):
+    def __init__(self, popen):
+        for attribute in dir(popen):
+            if attribute.startswith('__'):
+                continue
+            setattr(self, attribute, getattr(popen, attribute))
+
+    def __enter__(self):
+        return self
+
+    def __exit__(self, *args):
+        self.wait()
+
+
</ins><span class="cx"> class Executive(AbstractExecutive):
</span><span class="cx">     PIPE = subprocess.PIPE
</span><span class="cx">     STDOUT = subprocess.STDOUT
</span><span class="cx"> 
</span><del>-    class WrappedPopen(object):
-        def __init__(self, popen):
-            for attribute in dir(popen):
-                if attribute.startswith('__'):
-                    continue
-                setattr(self, attribute, getattr(popen, attribute))
-
-        def __enter__(self):
-            return self
-
-        def __exit__(self, *args):
-            self.wait()
-
</del><span class="cx">     def __init__(self):
</span><span class="cx">         self.pid_to_system_pid = {}
</span><span class="cx">         self._is_native_win = sys.platform.startswith('win')
</span><span class="lines">@@ -534,7 +535,7 @@
</span><span class="cx">         # Python 3 treats Popen as a context manager, we should allow this in Python 2
</span><span class="cx">         result = subprocess.Popen(string_args, env=env, **kwargs)
</span><span class="cx">         if not callable(getattr(result, "__enter__", None)) and not callable(getattr(result, "__exit__", None)):
</span><del>-            return self.WrappedPopen(result)
</del><ins>+            return WrappedPopen(result)
</ins><span class="cx">         return result
</span><span class="cx"> 
</span><span class="cx">     def run_in_parallel(self, command_lines_and_cwds, processes=None):
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportbasepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/base.py (278623 => 278624)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/base.py        2021-06-08 19:16:17 UTC (rev 278623)
+++ trunk/Tools/Scripts/webkitpy/port/base.py   2021-06-08 19:58:00 UTC (rev 278624)
</span><span class="lines">@@ -82,6 +82,9 @@
</span><span class="cx">     DEFAULT_DEVICE_TYPES = []
</span><span class="cx"> 
</span><span class="cx">     helper = None
</span><ins>+    _web_platform_test_server = None
+    _websocket_secure_server = None
+    _websocket_server = None
</ins><span class="cx"> 
</span><span class="cx">     @classmethod
</span><span class="cx">     def determine_full_port_name(cls, host, options, port_name):
</span><span class="lines">@@ -118,9 +121,6 @@
</span><span class="cx">         self.pretty_patch = PrettyPatch(self._executive, self.path_from_webkit_base(), self._filesystem)
</span><span class="cx"> 
</span><span class="cx">         self._http_server = None
</span><del>-        self._websocket_server = None
-        self._websocket_secure_server = None
-        self._web_platform_test_server = None
</del><span class="cx">         self._image_differ = None
</span><span class="cx">         self._server_process_constructor = server_process.ServerProcess  # overridable for testing
</span><span class="cx">         self._test_runner_process_constructor = server_process.ServerProcess
</span><span class="lines">@@ -863,12 +863,12 @@
</span><span class="cx">         ports = []
</span><span class="cx">         if self._http_server:
</span><span class="cx">             ports.extend(self._http_server.ports_to_forward())
</span><del>-        if self._websocket_server:
-            ports.extend(self._websocket_server.ports_to_forward())
-        if self._websocket_server:
-            ports.extend(self._websocket_secure_server.ports_to_forward())
-        if self._web_platform_test_server:
-            ports.extend(self._web_platform_test_server.ports_to_forward())
</del><ins>+        if Port._websocket_server:
+            ports.extend(Port._websocket_server.ports_to_forward())
+        if Port._websocket_server:
+            ports.extend(Port._websocket_secure_server.ports_to_forward())
+        if Port._web_platform_test_server:
+            ports.extend(Port._web_platform_test_server.ports_to_forward())
</ins><span class="cx">         return ports
</span><span class="cx"> 
</span><span class="cx">     def start_http_server(self, additional_dirs=None):
</span><span class="lines">@@ -894,12 +894,12 @@
</span><span class="cx">         return http_server_base.is_http_server_running()
</span><span class="cx"> 
</span><span class="cx">     def is_websocket_server_running(self):
</span><del>-        if self._websocket_server:
</del><ins>+        if Port._websocket_server:
</ins><span class="cx">             return True
</span><span class="cx">         return websocket_server.is_web_socket_server_running()
</span><span class="cx"> 
</span><span class="cx">     def is_wpt_server_running(self):
</span><del>-        if self._web_platform_test_server:
</del><ins>+        if Port._web_platform_test_server:
</ins><span class="cx">             return True
</span><span class="cx">         return web_platform_test_server.is_wpt_server_running(self)
</span><span class="cx"> 
</span><span class="lines">@@ -907,14 +907,14 @@
</span><span class="cx">         """Start a web server. Raise an error if it can't start or is already running.
</span><span class="cx"> 
</span><span class="cx">         Ports can stub this out if they don't need a websocket server to be running."""
</span><del>-        assert not self._websocket_server, 'Already running a websocket server.'
</del><ins>+        assert not Port._websocket_server, 'Already running a websocket server.'
</ins><span class="cx"> 
</span><span class="cx">         server = websocket_server.PyWebSocket(self, self.results_directory())
</span><span class="cx">         server.start()
</span><del>-        self._websocket_server = server
</del><ins>+        Port._websocket_server = server
</ins><span class="cx"> 
</span><span class="cx">         websocket_server_temporary_directory = self._filesystem.mkdtemp(prefix='webkitpy-websocket-server')
</span><del>-        self._websocket_server_temporary_directory = websocket_server_temporary_directory
</del><ins>+        Port._websocket_server_temporary_directory = websocket_server_temporary_directory
</ins><span class="cx"> 
</span><span class="cx">         pem_file = self._filesystem.join(self.layout_tests_dir(), "http", "conf", "webkit-httpd.pem")
</span><span class="cx">         pem = pemfile.load(self._filesystem, pem_file)
</span><span class="lines">@@ -923,16 +923,16 @@
</span><span class="cx">         private_key_file = self._filesystem.join(str(websocket_server_temporary_directory), 'webkit-httpd.key')
</span><span class="cx">         self._filesystem.write_text_file(private_key_file, pem.private_key)
</span><span class="cx"> 
</span><del>-        secure_server = self._websocket_secure_server = websocket_server.PyWebSocket(self, self.results_directory(),
</del><ins>+        secure_server = Port._websocket_secure_server = websocket_server.PyWebSocket(self, self.results_directory(),
</ins><span class="cx">             use_tls=True, port=websocket_server.PyWebSocket.DEFAULT_WSS_PORT, private_key=private_key_file, certificate=certificate_file)
</span><span class="cx">         secure_server.start()
</span><del>-        self._websocket_secure_server = secure_server
</del><ins>+        Port._websocket_secure_server = secure_server
</ins><span class="cx"> 
</span><span class="cx">     def start_web_platform_test_server(self, additional_dirs=None, number_of_servers=None):
</span><del>-        assert not self._web_platform_test_server, 'Already running a Web Platform Test server.'
</del><ins>+        assert not Port._web_platform_test_server, 'Already running a Web Platform Test server.'
</ins><span class="cx"> 
</span><del>-        self._web_platform_test_server = web_platform_test_server.WebPlatformTestServer(self, "wptwk")
-        self._web_platform_test_server.start()
</del><ins>+        Port._web_platform_test_server = web_platform_test_server.WebPlatformTestServer(self, "wptwk")
+        Port._web_platform_test_server.start()
</ins><span class="cx"> 
</span><span class="cx">     def web_platform_test_server_doc_root(self):
</span><span class="cx">         return web_platform_test_server.doc_root(self).replace('\\', self.TEST_PATH_SEPARATOR) + self.TEST_PATH_SEPARATOR
</span><span class="lines">@@ -971,19 +971,19 @@
</span><span class="cx"> 
</span><span class="cx">     def stop_websocket_server(self):
</span><span class="cx">         """Shut down the websocket server if it is running. Do nothing if it isn't."""
</span><del>-        if self._websocket_server:
-            self._websocket_server.stop()
-            self._websocket_server = None
-        if self._websocket_secure_server:
-            self._websocket_secure_server.stop()
-            self._websocket_secure_server = None
-        if self._websocket_server_temporary_directory:
-            self._filesystem.rmtree(str(self._websocket_server_temporary_directory))
</del><ins>+        if Port._websocket_server:
+            Port._websocket_server.stop()
+            Port._websocket_server = None
+        if Port._websocket_secure_server:
+            Port._websocket_secure_server.stop()
+            Port._websocket_secure_server = None
+        if Port._websocket_server_temporary_directory:
+            self._filesystem.rmtree(str(Port._websocket_server_temporary_directory))
</ins><span class="cx"> 
</span><span class="cx">     def stop_web_platform_test_server(self):
</span><del>-        if self._web_platform_test_server:
-            self._web_platform_test_server.stop()
-            self._web_platform_test_server = None
</del><ins>+        if Port._web_platform_test_server:
+            Port._web_platform_test_server.stop()
+            Port._web_platform_test_server = None
</ins><span class="cx"> 
</span><span class="cx">     def exit_code_from_summarized_results(self, unexpected_results):
</span><span class="cx">         """Given summarized results, compute the exit code to be returned by new-run-webkit-tests.
</span></span></pre>
</div>
</div>

</body>
</html>