From 2789824fcc685077eb1600416e0a84fb0cc6424a Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Tue, 16 Nov 2021 09:03:48 +0000 Subject: [PATCH] [FIX] core: dbname threadlocal in evented CDT Since #77735 the chrome runner uses a receiver thread to better handle the full-duplex nature of Chrome's websocket communication. However that thread was missing the `dbname` threadlocal, leading to some of the logging and reporting to be mis-configured, and thus the filtering on CI (runbot) to exlude any logging message emitted from the receiver thread, such as the screenshot notifications. Fix by passing the current `dbname` to the receiver thread when spawning it, and having said receiver start by setting up the threadlocal. closes odoo/odoo#79808 Signed-off-by: Xavier Morel (xmo) --- odoo/tests/common.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 2ac423f85a4..d45c55d8546 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -843,7 +843,11 @@ class ChromeBrowser: 'Page.frameStoppedLoading': self._handle_frame_stopped_loading, 'Page.screencastFrame': self._handle_screencast_frame, } - self._receiver = threading.Thread(target=self._receive, name="WebSocket events consumer") + self._receiver = threading.Thread( + target=self._receive, + name="WebSocket events consumer", + args=(get_db_name(),) + ) self._receiver.start() self._logger.info('Enable chrome headless console log notification') self._websocket_send('Runtime.enable') @@ -1033,7 +1037,8 @@ class ChromeBrowser: raise unittest.SkipTest("Cannot connect to chrome dev tools") self.ws.settimeout(0.01) - def _receive(self): + def _receive(self, dbname): + threading.current_thread().dbname = dbname # So CDT uses a streamed JSON-RPC structure, meaning a request is # {id, method, params} and eventually a {id, result | error} should # arrive the other way, however for events it uses "notifications"