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.
This commit is contained in:
James Graham 2018-04-24 17:12:06 +01:00
Родитель 7b20ac46dc
Коммит e1248b3d63
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -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,