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)