context thread lock
frdel committed
Sep 5, 2024 at 00:24 UTC
ee481f77112c6c7ee38b711fefc0140eea47ac7e
1 file changed
+4
-2
run_ui.py
+4
-2
@@ -16,6 +16,7 @@ from dotenv import load_dotenv
16
17
#initialize the internal Flask server
18
app = Flask("app",static_folder=get_abs_path("./webui"),static_url_path="/")
19
+lock = threading.Lock()
20
21
# Set up basic authentication, name and password from .env variables
22
app.config['BASIC_AUTH_USERNAME'] = os.environ.get('BASIC_AUTH_USERNAME') or "admin" #default name
@@ -24,8 +25,9 @@ basic_auth = BasicAuth(app)
25
26
# get context to run agent zero in
27
def get_context(ctxid:str):
27
- if not ctxid: return AgentContext.first() or AgentContext(config=initialize())
28
- return AgentContext.get(ctxid) or AgentContext(config=initialize(),id=ctxid)
28
+ with lock:
29
+ if not ctxid: return AgentContext.first() or AgentContext(config=initialize())
30
+ return AgentContext.get(ctxid) or AgentContext(config=initialize(),id=ctxid)
31
32
# Now you can use @requires_auth function decorator to require login on certain pages
33
def requires_auth(f):