Skip to content

Enable concurrent KedroSession usageΒ #5392

@nejox

Description

@nejox

Description

runtime_params OmegaConf resolver registration is process-global, breaking concurrent KedroSession usage

Context

When multiple KedroSession instances run concurrently in the same process (e.g. a FastAPI service triggering pipelines per request), OmegaConfigLoader registers _get_runtime_value as the runtime_params resolver with replace=True on every session creation β€” meaning Session B silently overwrites the resolver of Session A, causing requests to resolve each other's runtime parameters. In our case we created an API which triggers the kedro pipelines in the same kedro env where we interpolate filepaths based on a runtime_parameter ID which differ by request. Our deployment works with multiple KubernetesPods running one worker and leverage multithreading. While this seems only relevant during KedroCatalog creation (afaik) this became a problem in our project.

Possible Implementation

A backwards-compatible fix (brainstormed with Claude) could be to register the resolver once at module level backed by a contextvars.ContextVar, and set/reset the ContextVar in KedroSession.enter/exit β€” preserving all existing resolver behaviour (OmegaConf.select, nested params, default values, error handling) while achieving per-session isolation for both threaded and asyncio concurrency models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CommunityIssue/PR opened by the open-source communityIssue: Feature RequestNew feature or improvement to existing feature

    Type

    No type

    Projects

    Status

    Can be Groomed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions