Skip to content

Pinecone - add methods to close resources #1972

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

anakin87
Copy link
Member

Related Issues

Proposed Changes:

How did you test it?

CI

Test script

import asyncio
import random

from haystack_integrations.document_stores.pinecone.document_store import PineconeDocumentStore

namespaces = [
    "test_comparison_greater_than_equal_with_dataframe-1736932566",
    "test_comparison_greater_than_equal_with_string-1729243732",
    "test_comparison_greater_than_equal-1729243731",
    "test_comparison_greater_than_with_dataframe-1736932562",
    "test_comparison_in-1729158147",
    "test_comparison_less_than_with_dataframe-1729243742",
    "test_comparison_less_than_with_string-1729243740",
]

ds = PineconeDocumentStore(
    index="default",
    namespace=namespaces[0],
)
print(ds.count_documents())

async def test_namespace(namespace):
    ds = PineconeDocumentStore(index="default", namespace=namespace)
    try:
        await ds.filter_documents_async()
        num_documents = await ds.count_documents_async()
        print(f"Namespace {namespace}: {num_documents} documents")

        documents = await ds._embedding_retrieval_async(query_embedding=[0.1] * 768)

        if documents:
            print(f"First document: {documents[0]}")

    finally:
        # commenting the following line causes "Unclosed connector" errors
        await ds.close_async()

async def main():
    tasks = [
        test_namespace(random.choice(namespaces))
        for _ in range(5)
    ]
    await asyncio.gather(*tasks)

asyncio.run(main())

Checklist

@github-actions github-actions bot added integration:pinecone type:documentation Improvements or additions to documentation labels Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration:pinecone topic:CI type:documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant