Skip to content

Let SandboxToolset be deep-copied again - #74525

Merged
potiuk merged 2 commits into
apache:mainfrom
FrankYang0529:fix-common-ai-sandbox-toolset-deepcopy
Oct 10, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
FrankYang0529:fix-common-ai-sandbox-toolset-deepcopy

Conversation

@FrankYang0529

@FrankYang0529 FrankYang0529 commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

In #73898, SandboxToolset.__init__ creates a threading.Lock, and a lock cannot be deep-copied. As a result, copy.deepcopy() on a SandboxToolset, or on an operator that holds a SandboxToolset, raises TypeError: cannot pickle '_thread.lock' object. This didn't happen in 0.10.0.

This PR moves the lock to module level, so every SandboxToolset shares one lock. The Modal backend already keeps its _CLIENT_BUILD_LOCK at module level. The shared lock is not held during a backend call, so one toolset doesn't wait for another toolset's sandbox.


Was generative AI tooling used to co-author this PR?
  • Yes - Claude Code

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A module-level lock fits here. It only guards short state checks and is never held during the backend call, so sharing it between toolsets costs nothing. It also matches _CLIENT_BUILD_LOCK in the Modal backend.

I also checked the RC for other per-instance locks with the same deep-copy problem. _InOrder (tools/_from_toolset.py) is created per call inside airflow_tools_from_toolset, and _ContentOff (tools/tracing.py) is a module-level singleton. Neither ends up on an object that Airflow deep-copies.


Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting

@potiuk
potiuk marked this pull request as ready for review October 10, 2026 06:39
FrankYang0529 and others added 2 commits October 10, 2026 08:05
The lock is process-wide and also protects close and the open re-check, which the previous comment did not say.

Generated-by: Claude Opus 5
Claude-Session: https://claude.ai/code/session_014np1fVAxHmGaBFt3qebJ8x
@potiuk
potiuk force-pushed the fix-common-ai-sandbox-toolset-deepcopy branch from 533a01b to 20d891d Compare October 10, 2026 07:06
@potiuk
potiuk merged commit 65a8382 into apache:main Oct 10, 2026
84 checks passed
@FrankYang0529
FrankYang0529 deleted the fix-common-ai-sandbox-toolset-deepcopy branch October 10, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants