Skip to content

[Question] Had some queries around the context propagation example #176

Description

@Daanial11

Hi, was just implementing a context propagation interceptor based on this sample: https://github.com/temporalio/samples-python/blob/main/context_propagation/README.md

After a bit of experimentation, it seems like the the contextvar value is automatically restored to the previous value during multiple concurrent workflow runs and even after an activity finishes executing (if the var was updated inside the activity).

I was wondering if the ContextVar.reset() usage in the sample is redundant? or are there scenarios where it might have an effect?

I'm using a thread pool executor for my worker, so perhaps thats why it seems like ContextVar.reset() does not do anything? temporalio/sdk-python#263

Would it be safe to remove the resetting part when using a thread pool executor for activity tasks? And for workflows in general if I don't want the context vars state to leak between them?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions