Skip to content

Hack around a pydantic bug preventing GCing modules#199

Merged
msullivan merged 1 commit into
mainfrom
fix-exclude-if-gc-leak
Jul 9, 2026
Merged

Hack around a pydantic bug preventing GCing modules#199
msullivan merged 1 commit into
mainfrom
fix-exclude-if-gc-leak

Conversation

@msullivan

Copy link
Copy Markdown
Contributor

pydantic-core doesn't process exclude_if in its tp_traverse fields,
and so using exclude_if in the obvious way renders the module it is in
un-GCable.

This isn't a huge problem in basic use but contributes to serious
leaks when using sandboxed setups like Temporal/Vercel workflows.

Work around it by putting weakref.proxy in instead.

pydantic-core doesn't process exclude_if in its tp_traverse fields,
and so using exclude_if in the obvious way renders the module it is in
un-GCable.

This isn't a huge problem in basic use but contributes to serious
leaks when using sandboxed setups like Temporal/Vercel workflows.

Work around it by putting weakref.proxy in instead.
@msullivan
msullivan requested a review from anbuzin July 9, 2026 04:47
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment Jul 9, 2026 4:49am

@msullivan
msullivan merged commit bae3855 into main Jul 9, 2026
7 checks passed
@msullivan
msullivan deleted the fix-exclude-if-gc-leak branch July 9, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants