Skip to content

Add close() and close_async() to QdrantDocumentStore#3556

Open
ErenAta16 wants to merge 2 commits into
deepset-ai:mainfrom
ErenAta16:add-qdrant-close-methods
Open

Add close() and close_async() to QdrantDocumentStore#3556
ErenAta16 wants to merge 2 commits into
deepset-ai:mainfrom
ErenAta16:add-qdrant-close-methods

Conversation

@ErenAta16

Copy link
Copy Markdown

Closes #1628

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.

WeaviateDocumentStore, PineconeDocumentStore, and ValkeyDocumentStore already expose this same close()/close_async() pair (introduced in #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.

Usage after this PR:

document_store = QdrantDocumentStore(...)
try:
    document_store.write_documents(docs)
finally:
    document_store.close()

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 --check are clean, and mypy reports no issues.

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.
@ErenAta16 ErenAta16 requested a review from a team as a code owner July 7, 2026 00:38
@ErenAta16 ErenAta16 requested review from sjrl and removed request for a team July 7, 2026 00:38
@github-actions github-actions Bot added integration:qdrant type:documentation Improvements or additions to documentation labels Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Coverage report (qdrant)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/qdrant/src/haystack_integrations/document_stores/qdrant
  document_store.py
Project Total  

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.
@ErenAta16 ErenAta16 force-pushed the add-qdrant-close-methods branch from 46afe0b to 7f1a848 Compare July 7, 2026 00:46
@anakin87 anakin87 requested review from anakin87 and removed request for sjrl July 7, 2026 05:59
@anakin87 anakin87 self-assigned this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:qdrant type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document Store - closing resources

2 participants