From 0a2b139f9b2da8925c426ace87aa8cd9c8f37374 Mon Sep 17 00:00:00 2001 From: gleb Date: Fri, 5 Jun 2026 17:32:45 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20SyntaxError=20nonlocal=20=E2=80=94=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8=D1=82=D1=8C=20=D0=BD=D0=B0?= =?UTF-8?q?=20dict=20=5Fpl=5Fstate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ui.py b/ui.py index 09f3d44..0eccbd8 100644 --- a/ui.py +++ b/ui.py @@ -430,20 +430,17 @@ with tab_pipeline: evq_pl = queue.Queue() cb_pl = AgentCallback(evq_pl) all_pl_events: list[dict] = [] - pl_result = None - pl_error = None + _pl_state = {"result": None, "error": None} def _run_pipeline(): - nonlocal pl_result, pl_error async def _inner(): - nonlocal pl_result, pl_error try: - pl_result = await pl.ainvoke( + _pl_state["result"] = await pl.ainvoke( {"tasks": [], "current_index": 0, "results": [], "errors": []}, {"callbacks": [cb_pl]}, ) except Exception as e: - pl_error = str(e) + _pl_state["error"] = str(e) asyncio.run(_inner()) t_pl = threading.Thread(target=_run_pipeline, daemon=True) @@ -473,11 +470,11 @@ with tab_pipeline: st.markdown(f'
{html}
', unsafe_allow_html=True) - if pl_error: - st.error(pl_error) - elif pl_result: - results = pl_result.get("results", []) - errors = pl_result.get("errors", []) + if _pl_state["error"]: + st.error(_pl_state["error"]) + elif _pl_state["result"]: + results = _pl_state["result"].get("results", []) + errors = _pl_state["result"].get("errors", []) md = [f"### Результат: {len(results)} заданий\n"] for r in results: tid = r.get("task_id", "")