haystack/releasenotes/notes/preserve-context-async-pipeline-ce363ae95bbdb8bf.yaml
Sebastian Husch Lee 33115bcccb
fix: Copy context when using ThreadPoolExecutor in `AsyncPipeline.run_async (#9433)
* Copy context when using threadpoolexecutor in AsyncPipeline.run_async

* Add reno

* Add dev comment
2025-05-23 15:11:08 +02:00

6 lines
447 B
YAML

---
fixes:
- |
To properly preserve the context when AsyncPipeline with components that only have sync run methods we copy the context using contextvars.copy_context() and run the component using `ctx.run(...)` so we can preserve context like the active tracing span.
This now means if your component 1) only has a sync run method and 2) it logs something to the tracer then this trace will be properly nested within the parent context.