From 3aced46b193eee3a7522431cb94cb0d2f6bb6324 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 30 Jan 2017 10:48:27 +0800 Subject: [PATCH] dashboard: report lost connection with master. Closes #602 --- artiq/frontend/artiq_dashboard.py | 13 +++++++++++-- artiq/gui/models.py | 6 ++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/artiq/frontend/artiq_dashboard.py b/artiq/frontend/artiq_dashboard.py index 20804ac53..b3a06ddbf 100755 --- a/artiq/frontend/artiq_dashboard.py +++ b/artiq/frontend/artiq_dashboard.py @@ -108,12 +108,21 @@ def main(): atexit.register(client.close_rpc) rpc_clients[target] = client + disconnect_reported = False + def report_disconnect(): + nonlocal disconnect_reported + if not disconnect_reported: + logging.error("connection to master lost, " + "restart dashboard to reconnect") + disconnect_reported = True + sub_clients = dict() for notifier_name, modelf in (("explist", explorer.Model), ("explist_status", explorer.StatusUpdater), ("datasets", datasets.Model), ("schedule", schedule.Model)): - subscriber = ModelSubscriber(notifier_name, modelf) + subscriber = ModelSubscriber(notifier_name, modelf, + report_disconnect) loop.run_until_complete(subscriber.connect( args.server, args.port_notify)) atexit_register_coroutine(subscriber.close) @@ -121,7 +130,7 @@ def main(): broadcast_clients = dict() for target in "log", "ccb": - client = Receiver(target, []) + client = Receiver(target, [], report_disconnect) loop.run_until_complete(client.connect( args.server, args.port_broadcast)) atexit_register_coroutine(client.close) diff --git a/artiq/gui/models.py b/artiq/gui/models.py index 63ecd2a0b..9b9551593 100644 --- a/artiq/gui/models.py +++ b/artiq/gui/models.py @@ -22,9 +22,11 @@ class ModelManager: class ModelSubscriber(ModelManager, Subscriber): - def __init__(self, notifier_name, model_factory): + def __init__(self, notifier_name, model_factory, + disconnect_cb=None): ModelManager.__init__(self, model_factory) - Subscriber.__init__(self, notifier_name, self._create_model) + Subscriber.__init__(self, notifier_name, self._create_model, + disconnect_cb=disconnect_cb) class LocalModelManager(ModelManager):