Skip to content

Add namespace isolation for tasks #43

@conradbzura

Description

@conradbzura

Summary

Add a namespace parameter to the @wool.routine decorator that controls a task's access to global variables on a given worker. Default to a unique, isolated namespace per task invocation to prevent global state leakage between unrelated tasks.

Provide three modes:

  • None (default): unique, isolated namespace per invocation
  • Named string (e.g., "cached"): shared globals with other tasks using the same namespace key
  • wool.WORKER sentinel: opt into the previous behavior (shared worker globals)

Motivation

All routine tasks currently share the worker's global namespace. This causes global state to leak between unrelated tasks, making behavior unpredictable and preventing safe concurrent execution of tasks that rely on mutable globals. Namespace isolation with ephemeral state as the default enables safe concurrent execution while providing opt-in mechanisms for intentional state sharing when needed (e.g., @lru_cache).

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or capability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions