mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-09-28 01:01:12 -07:00
gfhome: use ws_connect now that it returns the client
ws_connect() returns the running WsClient, so gfhome no longer needs to build the client by hand to get a clean disconnect; the exit path uses WsClient.shutdown() to stop and join the socket thread.
This commit is contained in:
@@ -45,7 +45,7 @@ from queue import Queue
|
|||||||
from gfutilities.configuration import parse, get_cfg, log_level
|
from gfutilities.configuration import parse, get_cfg, log_level
|
||||||
from gfutilities.service.authentication import authenticate_machine
|
from gfutilities.service.authentication import authenticate_machine
|
||||||
from gfutilities.service.dispatch import dispatch_action, PULS_ACTIONS
|
from gfutilities.service.dispatch import dispatch_action, PULS_ACTIONS
|
||||||
from gfutilities.service.websocket import get_session, WsClient
|
from gfutilities.service.websocket import get_session, ws_connect
|
||||||
|
|
||||||
import ffmachine
|
import ffmachine
|
||||||
|
|
||||||
@@ -87,16 +87,11 @@ def home(machine, args) -> int:
|
|||||||
logger.error('sign-in to %s failed', get_cfg('SERVICE.SERVER_URL'))
|
logger.error('sign-in to %s failed', get_cfg('SERVICE.SERVER_URL'))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# ws_connect() discards the client object, which makes a clean
|
# No session passed: homing is a single short connect that never needs
|
||||||
# disconnect impossible - build the client directly instead.
|
# a reconnect token refresh.
|
||||||
ws = WsClient(q_rx, q_tx)
|
ws = ws_connect(q_rx, q_tx)
|
||||||
ws.start()
|
if not ws:
|
||||||
deadline = time.monotonic() + 16
|
|
||||||
while not ws.ready and time.monotonic() < deadline:
|
|
||||||
time.sleep(0.5)
|
|
||||||
if not ws.ready:
|
|
||||||
logger.error('web socket connection failed')
|
logger.error('web socket connection failed')
|
||||||
ws.stop = True
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
result = 2
|
result = 2
|
||||||
@@ -168,7 +163,7 @@ def home(machine, args) -> int:
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('final Z reference failed')
|
logger.exception('final Z reference failed')
|
||||||
result = 2
|
result = 2
|
||||||
ws.stop = True
|
ws.shutdown()
|
||||||
try:
|
try:
|
||||||
machine.stop()
|
machine.stop()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user