Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions openapi/templates/rest.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from typing import Dict, Optional

import httpx
from authlib.integrations.httpx_client import OAuth2Client
from httpx import Timeout, ConnectError
from httpx import Timeout, ConnectError, Limits

from rapidata.api_client.exceptions import ApiException, ApiValueError

Expand Down Expand Up @@ -229,12 +229,16 @@ class RESTClientObject:
return RESTResponse(r)

def _get_session_defaults(self):
# Set connection pool limits to support high concurrency uploads
limits = Limits(max_connections=200, max_keepalive_connections=200)

client_kwargs = {
"verify": (
self.configuration.ssl_ca_cert
if self.configuration.ssl_ca_cert
else self.configuration.verify_ssl
)
),
"limits": limits,
}

if self.configuration.proxy:
Expand All @@ -247,7 +251,7 @@ class RESTClientObject:
client_kwargs["headers"] = existing_headers

if self.configuration.retries is not None:
transport = httpx.HTTPTransport(retries=self.configuration.retries)
transport = httpx.HTTPTransport(retries=self.configuration.retries, limits=limits)
client_kwargs["transport"] = transport

return client_kwargs
Expand Down
10 changes: 7 additions & 3 deletions src/rapidata/api_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import httpx
from authlib.integrations.httpx_client import OAuth2Client
from httpx import Timeout, ConnectError
from httpx import Timeout, ConnectError, Limits

from rapidata.api_client.exceptions import ApiException, ApiValueError

Expand Down Expand Up @@ -239,12 +239,16 @@ def request(
return RESTResponse(r)

def _get_session_defaults(self):
# Set connection pool limits to support high concurrency uploads
limits = Limits(max_connections=200, max_keepalive_connections=200)

client_kwargs = {
"verify": (
self.configuration.ssl_ca_cert
if self.configuration.ssl_ca_cert
else self.configuration.verify_ssl
)
),
"limits": limits,
}

if self.configuration.proxy:
Expand All @@ -257,7 +261,7 @@ def _get_session_defaults(self):
client_kwargs["headers"] = existing_headers

if self.configuration.retries is not None:
transport = httpx.HTTPTransport(retries=self.configuration.retries)
transport = httpx.HTTPTransport(retries=self.configuration.retries, limits=limits)
client_kwargs["transport"] = transport

return client_kwargs
Expand Down