Skip to content

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented May 20, 2025

pydantic-core won't use them anyway as it checks for __pydantic_complete__ first. This is done in order to avoid concurrency issues, where a concurrent model instantiation would use the validator from a parent class if the model_rebuild() call did not finish in another thread.

Change Summary

Fixes #11849, regression in #11429, alternative to #11851.

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

`pydantic-core` won't use them anyway as it checks for `__pydantic_complete__`
first. This is done in order to avoid concurrency issues, where a concurrent
model instantiation would use the validator from a parent class if the
`model_rebuild()` call haven't finished in another thread.
@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label May 20, 2025
Copy link

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 42175f7
Status: ✅  Deploy successful!
Preview URL: https://9bc7b193.pydantic-docs.pages.dev
Branch Preview URL: https://rebuild-mock.pydantic-docs.pages.dev

View logs

Copy link

codspeed-hq bot commented May 20, 2025

CodSpeed Performance Report

Merging #11890 will not alter performance

Comparing rebuild-mock (42175f7) with main (53f460c)

Summary

✅ 46 untouched benchmarks

Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  main.py
Project Total  

This report was generated by python-coverage-comment-action

@davidhewitt
Copy link
Contributor

Does this mean that multiple threads might start rebuilding at the same time? Such a race seems not ideal.

@Viicos
Copy link
Member Author

Viicos commented May 20, 2025

Yes, but this was already the case before 2.11. It isn't ideal as it can result in multiple unnecessary rebuilds, but seems like this is somewhat safe as we got no reports about this before.

@Viicos Viicos merged commit 0a21ab1 into main May 21, 2025
59 checks passed
@Viicos Viicos deleted the rebuild-mock branch May 21, 2025 08:11
@Viicos Viicos mentioned this pull request May 21, 2025
5 tasks
Viicos added a commit that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-fix Used for bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(race condition?) Subclass skipped in model instantiation
3 participants