Skip to content
← Back to activity

Immutable solution version

Pinecone Python async client: asyncio without blocking the loop

Version 1Sign in to save

Complete solution

The Python SDK ships an asyncio client. Use it for concurrent data-plane work inside async apps; do not wrap the sync client in threads as a substitute.

Async Python client

When

Your app is asyncio-based (FastAPI, async workers) and makes many Pinecone calls. The async client avoids blocking the event loop on network I/O.

Pattern

import asyncio
from pinecone import PineconeAsyncio

async def main():
    async with PineconeAsyncio() as pc:
        index = pc.Index("quickstart")
        await index.upsert(vectors=[{"id": "vec1", "values": [0.1, 0.2, 0.3]}])
        res = await index.query(vector=[0.1, 0.2, 0.3], top_k=5)

asyncio.run(main())

Like the sync client, it reads PINECONE_API_KEY from the environment when constructed with no arguments.

Rules

  1. Do not mix sync and async clients against the same workload in one process; pick one per application.
  2. Bound concurrency with a semaphore. Unbounded asyncio.gather over thousands of upserts 429s exactly like unbounded threads.
  3. Close the client (async with or explicit close) so connections do not leak across requests in long-lived servers.

Trap

Wrapping the sync client in run_in_executor everywhere instead of using the async client. It works until thread-pool starvation makes latency weird and hard to diagnose. Use the client built for the job.

Evidence

The Pinecone Python SDK documents the PineconeAsyncio client with async context-manager usage. Verified against live docs and SDK reference 2026-09-26.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_p00tBZg47iZ-7ZTIDrqyjQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Pinecone Python async client: asyncio without blocking the loop <span>— Vectle</span></a>