diff --git a/neetbox/daemon/client/_action_agent.py b/neetbox/daemon/client/_action_agent.py index 18ed5e86..25c21eb8 100644 --- a/neetbox/daemon/client/_action_agent.py +++ b/neetbox/daemon/client/_action_agent.py @@ -62,6 +62,7 @@ def run_and_callback(target_action, params, callback): Thread( target=run_and_callback, kwargs={"target_action": target_action, "params": params, "callback": callback}, + daemon=True, ).start() return None else: # blocking run diff --git a/neetbox/daemon/client/_connection.py b/neetbox/daemon/client/_connection.py index 942cd3a4..c175ab43 100644 --- a/neetbox/daemon/client/_connection.py +++ b/neetbox/daemon/client/_connection.py @@ -49,10 +49,6 @@ class ClientConn(metaclass=Singleton): __ws_subscription = Registry("__client_ws_subscription") # { event-type-name : list(Callable)} def __init__(self) -> None: - cfg = get_module_level_config() - _root_config = get_module_level_config("@") - ClientConn._display_name = cfg["displayName"] or _root_config["name"] - def __load_http_client(): __local_http_client = httpx.Client( proxies={ @@ -67,6 +63,8 @@ def __load_http_client(): def _init_ws(): cfg = get_module_level_config() + _root_config = get_module_level_config("@") + ClientConn._display_name = cfg["displayName"] or _root_config["name"] # ws server url ClientConn.ws_server_addr = f"ws://{cfg['host']}:{cfg['port'] + 1}{CLIENT_API_ROOT}" @@ -83,7 +81,7 @@ def _init_ws(): on_close=ClientConn.__on_ws_close, ) - Thread(target=ws.run_forever, kwargs={"reconnect": True}).start() + Thread(target=ws.run_forever, kwargs={"reconnect": True}, daemon=True).start() # assign self to websocket log writer from neetbox.logging._writer import _assign_connection_to_WebSocketLogWriter diff --git a/neetbox/daemon/client/_daemon_client.py b/neetbox/daemon/client/_daemon_client.py index 4841c7b1..6ffa701e 100644 --- a/neetbox/daemon/client/_daemon_client.py +++ b/neetbox/daemon/client/_daemon_client.py @@ -91,9 +91,7 @@ def _check_daemon_alive(_api_addr): global __upload_thread if __upload_thread is None or not __upload_thread.is_alive(): __upload_thread = Thread( - target=_upload_thread, - daemon=True, - args=[cfg, _base_addr, _display_name], + target=_upload_thread, args=[cfg, _base_addr, _display_name], daemon=True ) __upload_thread.start() diff --git a/neetbox/pipeline/_signal_and_slot.py b/neetbox/pipeline/_signal_and_slot.py index 5acb99dd..9f76f6ab 100644 --- a/neetbox/pipeline/_signal_and_slot.py +++ b/neetbox/pipeline/_signal_and_slot.py @@ -75,7 +75,9 @@ def _so_update_and_ping_listen(_name, _value, _watch_config): f"Watched value {_name} takes longer time({delta_t:.8f}s) to update than it was expected({expected_time_limit}s)." ) - Thread(target=_so_update_and_ping_listen, args=(name, _the_value, _watch_config)).start() + Thread( + target=_so_update_and_ping_listen, args=(name, _the_value, _watch_config), daemon=True + ).start() return _the_value diff --git a/pyproject.toml b/pyproject.toml index 2a29c61c..46c49a15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,8 +45,8 @@ pytest = "^7.4.3" pyfiglet = "^1.0.2" httpx = "^0.24.0" flask = "^2.2.3" -flask-socketio = "^5.3.6" websocket-client = "^1.6.4" +websocket-server = "^0.6.4" [tool.poetry.group.dev.dependencies] pytest = "^7.0.0"