From dae0586cc8636a9763e037a9b16ea55030954653 Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 25 Mar 2024 17:15:42 +0800 Subject: [PATCH] concurrent access to interactive args throws error --- artiq/language/environment.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/artiq/language/environment.py b/artiq/language/environment.py index 8b4076a4c..fc7ae2a78 100644 --- a/artiq/language/environment.py +++ b/artiq/language/environment.py @@ -2,6 +2,7 @@ from collections import OrderedDict from inspect import isclass from contextlib import contextmanager from types import SimpleNamespace +import threading from sipyco import pyon @@ -262,6 +263,7 @@ class HasEnvironment: self.__in_build = True self.build(*args, **kwargs) self.__in_build = False + self.__interactive_semaphore = threading.Semaphore() def register_child(self, child): self.children.append(child) @@ -349,7 +351,10 @@ class HasEnvironment: namespace.setattr_argument = setattr_argument yield namespace del namespace.setattr_argument + if not self.__interactive_semaphore.acquire(blocking=False): + raise RuntimeError("concurrent calls to interactive with the same RID is not supported") argdict = self.__argument_mgr.get_interactive(interactive_arglist, title) + self.__interactive_semaphore.release() for key, value in argdict.items(): setattr(namespace, key, value)