[Python] Connection pooling with httpx.Client

Discussão em 'Python' iniciado por Stack, Abril 28, 2025.

  1. Stack

    Stack Membro Participativo

    The clients section in the httpx docs mention connection pooling and generally recommend the use of httpx.Client.

    I cannot read from the docs or from anywhere else however, if connection pooling is simply tied to an httpx.Client instance or if calling open/close or entering/exiting a client context manager affects connection pooling.

    E.g. if connection pooling was simply tied to a client instance the following should be able to benefit from pooling:

    shared_client = httpx.Client()

    with shared_client as client:
    # do stuff

    with shared_client as client:
    # do more stuff


    If connection pooling was affected by close or exiting a client context, the above would not be able to utilize pooling.

    I would appreciate any help on this.

    Continue reading...

Compartilhe esta Página