From 34220d176510811628b42439d26afcdf6e09ed89 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 18 Apr 2021 21:17:41 +0100 Subject: [PATCH] Set some process titles. --- controllers/mattchbox_usb.py | 2 +- helpers/os_environment.py | 2 -- server.py | 8 +++++++- websocket_server.py | 6 ++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/controllers/mattchbox_usb.py b/controllers/mattchbox_usb.py index 14eb4a9..18123dd 100644 --- a/controllers/mattchbox_usb.py +++ b/controllers/mattchbox_usb.py @@ -24,10 +24,10 @@ class MattchBox(Controller): process_title = "ControllerHandler" setproctitle(process_title) + current_process().name = process_title self.ser = None self.logger = LoggingManager("ControllerMattchBox") - current_process().name = process_title self.server_state = state # This is a copy, will not update :/ diff --git a/helpers/os_environment.py b/helpers/os_environment.py index be0b991..15c8c37 100644 --- a/helpers/os_environment.py +++ b/helpers/os_environment.py @@ -35,8 +35,6 @@ def resolve_local_file_path(relative_path: str): except Exception: base_path = os.path.abspath(".") - print("LOCAL PATH:", os.path.join(base_path, relative_path)) - return os.path.join(base_path, relative_path) diff --git a/server.py b/server.py index 3b20c04..6ab2610 100644 --- a/server.py +++ b/server.py @@ -149,7 +149,7 @@ class BAPSicleServer: process_title = "startServer" setproctitle(process_title) - # multiprocessing.current_process().name = process_title + multiprocessing.current_process().name = process_title self.logger = LoggingManager("BAPSicleServer") @@ -224,6 +224,7 @@ class BAPSicleServer: self.websocket_to_q[0].put("WEBSOCKET:QUIT") if self.websockets_server: self.websockets_server.join() + del self.websockets_server print("Stopping Players") for q in self.player_to_q: @@ -232,20 +233,25 @@ class BAPSicleServer: for player in self.player: player.join() + del self.player + print("Stopping Web Server") if self.webserver: self.webserver.terminate() self.webserver.join() + del self.webserver print("Stopping Player Handler") if self.player_handler: self.player_handler.terminate() self.player_handler.join() + del self.player_handler print("Stopping Controllers") if self.controller_handler: self.controller_handler.terminate() self.controller_handler.join() + del self.controller_handler if __name__ == "__main__": diff --git a/websocket_server.py b/websocket_server.py index fea6447..5dbd7ec 100644 --- a/websocket_server.py +++ b/websocket_server.py @@ -8,6 +8,8 @@ import websockets import json from os import _exit from websockets.server import Serve +from setproctitle import setproctitle +from multiprocessing import current_process from helpers.logging_manager import LoggingManager from helpers.the_terminator import Terminator @@ -30,6 +32,10 @@ class WebsocketServer: self.channel_to_q = in_q self.webstudio_to_q = out_q + process_title = "Websockets Servr" + setproctitle(process_title) + current_process().name = process_title + self.logger = LoggingManager("Websockets") self.server_name = state.get()["server_name"]