start event loop early
This commit is contained in:
@@ -964,7 +964,7 @@ async def ws_serve(websocket, path):
|
||||
|
||||
|
||||
def websocketupdater():
|
||||
loop.run_forever()
|
||||
pass
|
||||
|
||||
|
||||
def msg_to_websockets(typ: str, msg: str):
|
||||
@@ -1222,9 +1222,15 @@ except:
|
||||
print(("failed to start server on %s:%s" % (hbd_host, hbd_port)))
|
||||
sys.exit(1)
|
||||
|
||||
if verbose:
|
||||
print("http server started")
|
||||
#
|
||||
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
if verbose:
|
||||
print("asyncio event lop at %s" % loop)
|
||||
|
||||
|
||||
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||
wss_pem = pathlib.Path(WSS_PEM)
|
||||
@@ -1234,15 +1240,6 @@ try:
|
||||
except FileNotFoundError:
|
||||
print(("warning: missing %s or %s" % (wss_pem, wss_key)))
|
||||
sys.exit(1)
|
||||
wss_start_server = websockets.serve(
|
||||
ws_serve, hbd_host, WSSPORT, ssl=ssl_context, loop=loop, subprotocols=["hbd"]
|
||||
)
|
||||
loop.run_until_complete(wss_start_server)
|
||||
|
||||
ws_start_server = websockets.serve(
|
||||
ws_serve, hbd_host, WSPORT, loop=loop, subprotocols=["hbd"]
|
||||
)
|
||||
loop.run_until_complete(ws_start_server)
|
||||
|
||||
servthread = threading.Thread(target=serv.serve_forever)
|
||||
servthread.daemon = True
|
||||
@@ -1255,6 +1252,19 @@ dnsT.start()
|
||||
wsT = threading.Thread(target=websocketupdater)
|
||||
wsT.daemon = True
|
||||
wsT.start()
|
||||
loop.run_forever()
|
||||
if verbose:
|
||||
print("run_forever()")
|
||||
|
||||
wss_start_server = websockets.serve(
|
||||
ws_serve, hbd_host, WSSPORT, ssl=ssl_context, loop=loop, subprotocols=["hbd"]
|
||||
)
|
||||
loop.run_until_complete(wss_start_server)
|
||||
|
||||
ws_start_server = websockets.serve(
|
||||
ws_serve, hbd_host, WSPORT, loop=loop, subprotocols=["hbd"]
|
||||
)
|
||||
loop.run_until_complete(ws_start_server)
|
||||
|
||||
running = True
|
||||
sig = 0
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
websockets>=8.1
|
||||
websockets>=13.2
|
||||
mattermostdriver>=7.3.0
|
||||
|
||||
Reference in New Issue
Block a user