Try to unlock the global lock in StructuredLogger after reloading logging

This should finally fix all the websockets related failures we've been
seeing lately.
This commit is contained in:
Bastien Orivel 2018-09-18 21:29:37 +02:00
parent 82e94e3b67
commit c692094225
2 changed files with 9 additions and 5 deletions

View file

@ -650026,7 +650026,7 @@
"support" "support"
], ],
"tools/serve/serve.py": [ "tools/serve/serve.py": [
"31a08dbd016752db5925410dbf5435a0e8623981", "104701caf85ba2250d4c844650025517f0d473b6",
"support" "support"
], ],
"tools/serve/test_functional.py": [ "tools/serve/test_functional.py": [

View file

@ -19,8 +19,10 @@ from collections import defaultdict, OrderedDict
from multiprocessing import Process, Event from multiprocessing import Process, Event
from localpaths import repo_root from localpaths import repo_root
from six.moves import reload_module
from manifest.sourcefile import read_script_metadata, js_meta_re, parse_variants from manifest.sourcefile import read_script_metadata, js_meta_re, parse_variants
from mozlog.structuredlog import StructuredLogger
from wptserve import server as wptserve, handlers from wptserve import server as wptserve, handlers
from wptserve import stash from wptserve import stash
from wptserve import config from wptserve import config
@ -631,9 +633,10 @@ class WebSocketDaemon(object):
def start_ws_server(host, port, paths, routes, bind_address, config, **kwargs): def start_ws_server(host, port, paths, routes, bind_address, config, **kwargs):
# Ensure that when we start this in a new process we have the global lock # Ensure that when we start this in a new process we have the global lock
# in the logging module unlocked # in the logging module unlocked
reload_module(logging)
try: try:
logging._releaseLock() StructuredLogger._lock.release()
except RuntimeError: except threading.ThreadError:
pass pass
return WebSocketDaemon(host, return WebSocketDaemon(host,
str(port), str(port),
@ -647,9 +650,10 @@ def start_ws_server(host, port, paths, routes, bind_address, config, **kwargs):
def start_wss_server(host, port, paths, routes, bind_address, config, **kwargs): def start_wss_server(host, port, paths, routes, bind_address, config, **kwargs):
# Ensure that when we start this in a new process we have the global lock # Ensure that when we start this in a new process we have the global lock
# in the logging module unlocked # in the logging module unlocked
reload_module(logging)
try: try:
logging._releaseLock() StructuredLogger._lock.release()
except RuntimeError: except threading.ThreadError:
pass pass
return WebSocketDaemon(host, return WebSocketDaemon(host,
str(port), str(port),