-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add experimental support for free threading #11516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Similar logic to the recursion state
Nothing we can really do on these ones, the `generate_schema_calls` fixture monkeypatches code and this will happen across threads.
Deploying pydantic-docs with
|
Latest commit: |
03d03fd
|
Status: | ✅ Deploy successful! |
Preview URL: | https://fdfb6bc1.pydantic-docs.pages.dev |
Branch Preview URL: | https://freethreaded.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #11516 will not alter performanceComparing Summary
|
@@ -2149,6 +2150,7 @@ class Yard(BaseModel): | |||
assert str(yard_dict['pet']['type']) == 'dog' | |||
|
|||
|
|||
@pytest.mark.thread_unsafe(reason='Passes on multithreaded. This needs to be investigated further.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While all the other tests marked as thread unsafe made sense, I have no idea why this one passes. Core schemas are identical, and verified it isn't a late lambda binding issue. Might be something in core?
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM with one question!
@@ -94,7 +94,7 @@ def __delitem__(self, key: KT) -> None: | |||
# and discover later on that we need to re-add all this infrastructure... | |||
# _GENERIC_TYPES_CACHE = DeepChainMap(GenericTypesCache(), LimitedDict()) | |||
|
|||
_GENERIC_TYPES_CACHE = GenericTypesCache() | |||
_GENERIC_TYPES_CACHE: ContextVar[GenericTypesCache | None] = ContextVar('_GENERIC_TYPES_CACHE', default=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is to make a separate cache for each thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly, identical to the recursion cache:
pydantic/pydantic/_internal/_generics.py
Line 396 in bff7477
_generic_recursion_cache: ContextVar[set[str] | None] = ContextVar('_generic_recursion_cache', default=None) |
Makes sense to get this into the 2nd beta next week 👍 |
Change Summary
Fixes #10483.
Related issue number
Checklist