concurrent access to interactive args throws error

This commit is contained in:
Simon Renblad 2024-03-25 17:15:42 +08:00
parent 329e7189cc
commit dae0586cc8

View File

@ -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)