Skip to content

Add namespace isolation for routine tasks #104

@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).

Affected code

  • wool/src/wool/runtime/routine/task.py — task deserialization and namespace management
  • wool/src/wool/runtime/routine/wrapper.py — decorator and namespace parameter handling
  • wool/src/wool/__init__.py — export WORKER sentinel
  • wool/protobuf/task.proto — add namespace field to protobuf schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or capability

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions