Ensure use of cachetools is thread-safe#2178
Merged
Robert Yokota (rayokota) merged 3 commits intomasterfrom Jan 26, 2026
Merged
Ensure use of cachetools is thread-safe#2178Robert Yokota (rayokota) merged 3 commits intomasterfrom
Robert Yokota (rayokota) merged 3 commits intomasterfrom
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There was a problem hiding this comment.
Pull request overview
This PR aims to make cachetools usage safe under concurrency by protecting cache access with locks across both sync and async Schema Registry clients and JSON schema validator caches.
Changes:
- Add locking around “latest schema” caches in sync/async
SchemaRegistryClientimplementations. - Add locking around JSON Schema validator LRU caches (sync and async).
- Update unasync generation rules and apply formatting/import-order adjustments across tests and modules.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/unasync.py | Updates unasync substitutions to convert asyncio locks/usages into threading locks for sync output. |
| src/confluent_kafka/schema_registry/_sync/schema_registry_client.py | Adds a threading lock to guard cachetools “latest” caches. |
| src/confluent_kafka/schema_registry/_async/schema_registry_client.py | Adds an asyncio lock to guard cachetools “latest” caches and updates cache-clearing methods. |
| src/confluent_kafka/schema_registry/_sync/json_schema.py | Adds a threading lock to guard JSON Schema validator LRU cache. |
| src/confluent_kafka/schema_registry/_async/json_schema.py | Adds an asyncio lock and makes validator retrieval awaitable. |
| src/confluent_kafka/schema_registry/_sync/avro.py | Formatting/import grouping changes (no functional logic change shown in diff). |
| src/confluent_kafka/schema_registry/_sync/protobuf.py | Formatting/whitespace changes (no functional logic change shown in diff). |
| tests/schema_registry/_sync/test_json_serdes.py | Reorders imports/formatting. |
| tests/schema_registry/_sync/test_json.py | Reorders imports/formatting. |
| tests/schema_registry/_sync/test_avro_serdes.py | Reorders imports/formatting. |
| tests/schema_registry/_sync/test_avro.py | Formats long lines for serializer construction. |
| tests/schema_registry/_sync/test_api_client.py | Reorders imports and formats a long test signature. |
| tests/integration/schema_registry/_sync/test_json_serializers.py | Reorders imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Justin Wang (Claimundefine)
approved these changes
Jan 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




What
Ensure use of cachetools is thread-safe
Checklist
References
JIRA:
Test & Review
Open questions / Follow-ups