From 2eb89cb1682bd338cb29992516c5a2e38802ac5f Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 30 Sep 2023 00:14:30 +0100 Subject: [PATCH] dashboard: Fix occasional "unexpected action" applet errors on startup This turned out to be a race between the dashboard's dataset db subscriber being initialised and the applet "embed" request, with artiq.applet.simple not being able to handle the unexpected "mod" message. We were only handling the other ordering outcome of this race before. --- artiq/gui/applets.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/artiq/gui/applets.py b/artiq/gui/applets.py index ac1db098d..c52d3a9d8 100644 --- a/artiq/gui/applets.py +++ b/artiq/gui/applets.py @@ -51,6 +51,13 @@ class AppletIPCServer(AsyncioParentComm): def _on_mod(self, mod): if mod["action"] == "init": + if not (self.datasets or self.dataset_prefixes): + # The dataset db connection just came online, and an applet is + # running but did not call `subscribe` yet (e.g. because the + # dashboard was just restarted and a previously enabled applet + # is being re-opened). We will later synthesize an "init" `mod` + # message once the applet actually subscribes. + return mod = self._synthesize_init(mod["struct"]) else: if mod["path"]: