From e1248b3d6356d9487142e2b0034cbaf09cbc9ac8 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 24 Apr 2018 17:12:06 +0100 Subject: [PATCH] Bug 1456525 - Fix wpt ws[s] server intermittent startup issue, r=ato Running wpt occasionally failed due to an issue starting the ws[s] servers. This turns out to be a deadlock caused by a logging lock being inherited into the child process, sometimes in a locked state. As a workaround, after spawning the subprocess, we reload the logging module in order to clear any existing lock. This is pretty much a hack, but it's the fastest path to a solution to a critical issue. --- testing/web-platform/tests/tools/serve/serve.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/testing/web-platform/tests/tools/serve/serve.py b/testing/web-platform/tests/tools/serve/serve.py index fb6675da42dd..ad26e6b748a6 100644 --- a/testing/web-platform/tests/tools/serve/serve.py +++ b/testing/web-platform/tests/tools/serve/serve.py @@ -5,8 +5,8 @@ from __future__ import print_function import abc import argparse import json +import logging import os -import re import socket import sys import threading @@ -19,7 +19,6 @@ from multiprocessing import Process, Event from localpaths import repo_root -import sslutils from manifest.sourcefile import read_script_metadata, js_meta_re from wptserve import server as wptserve, handlers from wptserve import stash @@ -29,6 +28,7 @@ from wptserve.handlers import filesystem_path, wrap_pipeline from wptserve.utils import get_port from mod_pywebsocket import standalone as pywebsocket + def replace_end(s, old, new): """ Given a string `s` that ends with `old`, replace that occurrence of `old` @@ -494,6 +494,9 @@ class WebSocketDaemon(object): def start_ws_server(host, port, paths, routes, bind_address, config, ssl_config, **kwargs): + # Ensure that when we start this in a new process we don't inherit the + # global lock in the logging module + reload(logging) return WebSocketDaemon(host, str(port), repo_root, @@ -505,6 +508,9 @@ def start_ws_server(host, port, paths, routes, bind_address, config, ssl_config, def start_wss_server(host, port, paths, routes, bind_address, config, ssl_config, **kwargs): + # Ensure that when we start this in a new process we don't inherit the + # global lock in the logging module + reload(logging) return WebSocketDaemon(host, str(port), repo_root,