Skip to content
Snippets Groups Projects
Commit daded012 authored by tsm-odoo's avatar tsm-odoo
Browse files

[FIX] bus: fix threads can only be started once


The `ImDispatch` thread uses the `thread.is_alive` method to check
whether or not the thread should be started. The issue is that, this
method will return `False` after the start method has been called, but
before the run method is invoked leading to the RuntimeError: thread
can only be started once.

This commit fixes this issue by suppressing this error in this case.

closes odoo/odoo#103153

Signed-off-by: default avatarAlexandre Kühn (aku) <aku@odoo.com>
parent fa58938b
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
import contextlib
import datetime
import json
import logging
......@@ -130,8 +131,9 @@ class ImDispatch(threading.Thread):
outdated_channels = websocket._channels - channels
self._clear_outdated_channels(websocket, outdated_channels)
websocket.subscribe(channels, last)
if not self.is_alive():
self.start()
with contextlib.suppress(RuntimeError):
if not self.is_alive():
self.start()
def unsubscribe(self, websocket):
self._clear_outdated_channels(websocket, websocket._channels)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment