Add close() and close_async() to QdrantDocumentStore#3556
Open
ErenAta16 wants to merge 2 commits into
Open
Conversation
QdrantDocumentStore lazily creates a QdrantClient and AsyncQdrantClient on first use but never released either one, so long-running processes and test suites had no way to release the underlying HTTP connections. Weaviate, Pinecone, and Valkey document stores already expose this same close()/close_async() pair (see deepset-ai#2891), so this follows the same convention: each method releases its respective client and resets it to None, letting it be lazily re-initialized on the next call. Addresses deepset-ai#1628.
Contributor
Coverage report (qdrant)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Covers the normal case (client is initialized, then released and lazily re-created on the next call) and the safety case (calling close before the client was ever initialized should be a no-op) for both the sync and async client. Added to the existing non-integration unit test classes rather than the integration-marked ones, since these only need Qdrant's in-memory mode and should run as part of the regular unit/coverage job.
46afe0b to
7f1a848
Compare
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.
Closes #1628
QdrantDocumentStore lazily creates a
QdrantClientandAsyncQdrantClienton first use but never released either one, so long-running processes and test suites had no way to release the underlying HTTP connections.WeaviateDocumentStore,PineconeDocumentStore, andValkeyDocumentStorealready expose this sameclose()/close_async()pair (introduced in #2891), so this follows the same convention: each method releases its respective client and resets it toNone, letting it be lazily re-initialized on the next call.Usage after this PR:
Test plan: four new tests covering the sync and async client, both the normal case (initialize, close, verify it's
None, confirm lazy re-initialization still works) and the safety case (calling close before the client was ever created should be a no-op). All use Qdrant's:memory:mode, so no external server is required.Verified locally: all 260 existing + new tests pass,
ruff check/ruff format --checkare clean, andmypyreports no issues.