fix: shutdown trace manager, not the executor, between jobs#1800
fix: shutdown trace manager, not the executor, between jobs#1800andreiancuta-uipath wants to merge 3 commits into
Conversation
db967c6 to
ecb4a6a
Compare
There was a problem hiding this comment.
Pull request overview
Adjusts the UiPath CLI’s tracing lifecycle so per-job tracing resources are shut down via UiPathTraceManager.shutdown() (instead of manually shutting down only the live-tracking processor), and bumps the uipath package version.
Changes:
- Update
uipath runanduipath debugto calltrace_manager.shutdown()in afinallyblock after runtime disposal. - Bump
uipathversion to2.13.4(and update lockfile accordingly). - Add a new planning/review markdown document (currently appears unrelated to this PR’s title/scope).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plan/review-import-cycle-duplication-plan.md | Adds a review-plan document (appears unrelated to trace-manager shutdown change). |
| packages/uipath/src/uipath/_cli/cli_run.py | Switches teardown to trace_manager.shutdown() and inlines live span processor construction. |
| packages/uipath/src/uipath/_cli/cli_debug.py | Same teardown change as cli_run.py for debug execution. |
| packages/uipath/pyproject.toml | Bumps package version to 2.13.4. |
| packages/uipath/uv.lock | Updates locked uipath version to 2.13.4. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4c08721 to
c7f0af6
Compare
c7f0af6 to
88d1292
Compare
|
🚨 Heads up:
|
|
Sonar coverage complains about an exception branch that logs. Not an essential path |


Regression introduced here.
LiveTrackingSpanProcessor.shutdown()only shuts down its internal ThreadPoolExecutor. It does not remove the processor from OpenTelemetry’s process-wide processor list. After that, the processor is dead but still subscribed to span start/end events, so the next job’s span is still delivered to job 1’s processor. Since that is shutdown, we get an error:RuntimeError: cannot schedule new futures after shutdownsequenceDiagram participant Server as cli_server.handle_start participant Run as cli_run.run participant TM as UiPathTraceManager participant DSP as _DelegatingSpanProcessor participant Live1 as job 1 LiveTrackingSpanProcessor participant Exec1 as job 1 ThreadPoolExecutor participant Live2 as job 2 LiveTrackingSpanProcessor participant Exec2 as job 2 ThreadPoolExecutor Server->>Run: job 1 via asyncio.to_thread(cmd.main, ...) Run->>TM: create trace manager Run->>Live1: create live tracking processor Run->>TM: add_span_processor(live1) TM->>DSP: add(live1) Run->>DSP: traced job 1 span starts DSP->>Live1: on_start(span) Live1->>Exec1: submit(upsert_span) Run->>Live1: live1.shutdown() Live1->>Exec1: shutdown(wait=True) Note over DSP,Live1: live1 is shut down but still registered Server->>Run: job 2 in the same process Run->>TM: create new trace manager Run->>Live2: create live tracking processor Run->>TM: add_span_processor(live2) TM->>DSP: add(live2) Run->>DSP: traced job 2 first span starts DSP->>Live1: on_start(span) Live1->>Exec1: submit(upsert_span) Exec1-->>Live1: RuntimeError: cannot schedule new futures after shutdown Live1-->>DSP: exception propagates DSP-->>Run: span start fails before job 2 code runs Run-->>Server: result file is written as faulted Note over Live2,Exec2: live2 would be able to send job 2 spans, but live1 crashes firstFix:
uipath serverand 2 agent jobs, and validated the fix the same way.