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
setproctitle("BAPSicleServer.py")
logger: LoggingManager
state: StateManager
class BAPSicleServer():
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()
def __del__(self):
@ -84,6 +70,9 @@ default_state = {
app = Flask(__name__, static_url_path='')
logger: LoggingManager
state: StateManager
api_from_q: queue.Queue
api_to_q: queue.Queue
@ -502,8 +491,15 @@ def serve_static(path: str):
def startServer():
process_title = "startServer"
#threading.current_thread().name = 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():
multiprocessing.set_start_method("spawn", True)
@ -574,6 +570,8 @@ def startServer():
# Don't use reloader, it causes Nested Processes!
def runWebServer():
process_title = "WebServer"
setproctitle(process_title)
CORS(app, supports_credentials=True) # Allow ALL CORS!!!
log = logging.getLogger('werkzeug')