Tidy up init for flake8.

This commit is contained in:
Matthew Stratford 2021-04-07 21:13:19 +01:00
parent 5d9e2364e4
commit 2297203896

View file

@ -41,24 +41,10 @@ from helpers.logging_manager import LoggingManager
from websocket_server import WebsocketServer from websocket_server import WebsocketServer
setproctitle("BAPSicleServer.py") setproctitle("BAPSicleServer.py")
logger: LoggingManager
state: StateManager
class BAPSicleServer(): class BAPSicleServer():
def __init__(self): def __init__(self):
process_title = "BAPSicleServer"
setproctitle(process_title)
#multiprocessing.current_process().name = process_title
global logger
global state
logger = LoggingManager("BAPSicleServer")
state = StateManager("BAPSicleServer", logger, default_state)
state.update("server_version", config.VERSION)
startServer() startServer()
def __del__(self): def __del__(self):
@ -84,6 +70,9 @@ default_state = {
app = Flask(__name__, static_url_path='') app = Flask(__name__, static_url_path='')
logger: LoggingManager
state: StateManager
api_from_q: queue.Queue api_from_q: queue.Queue
api_to_q: queue.Queue api_to_q: queue.Queue
@ -501,9 +490,16 @@ def serve_static(path: str):
return send_from_directory('ui-static', path) return send_from_directory('ui-static', path)
def startServer(): def startServer():
process_title="startServer" process_title = "startServer"
#threading.current_thread().name = process_title
setproctitle(process_title) setproctitle(process_title)
#multiprocessing.current_process().name = process_title
global logger
global state
logger = LoggingManager("BAPSicleServer")
state = StateManager("BAPSicleServer", logger, default_state)
state.update("server_version", config.VERSION)
if isMacOS(): if isMacOS():
multiprocessing.set_start_method("spawn", True) multiprocessing.set_start_method("spawn", True)
@ -574,6 +570,8 @@ def startServer():
# Don't use reloader, it causes Nested Processes! # Don't use reloader, it causes Nested Processes!
def runWebServer(): def runWebServer():
process_title = "WebServer"
setproctitle(process_title)
CORS(app, supports_credentials=True) # Allow ALL CORS!!! CORS(app, supports_credentials=True) # Allow ALL CORS!!!
log = logging.getLogger('werkzeug') log = logging.getLogger('werkzeug')