Skip to content

Commit

Permalink
Fix for urllib<2
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Oct 1, 2024
1 parent 454622b commit d8d582f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import warnings
import weakref
from dataclasses import dataclass, field
from inspect import signature
from queue import Empty, PriorityQueue, Queue
from typing import (
TYPE_CHECKING,
Expand All @@ -65,6 +66,7 @@
from requests import adapters as requests_adapters
from requests_toolbelt.multipart import MultipartEncoder # type: ignore[import-untyped]
from typing_extensions import TypeGuard
from urllib3.poolmanager import PoolKey
from urllib3.util import Retry

import langsmith
Expand Down Expand Up @@ -95,6 +97,7 @@ class ZoneInfo: # type: ignore[no-redef]
EMPTY_SEQ: tuple[Dict, ...] = ()
BOUNDARY = uuid.uuid4().hex
MultipartParts = List[Tuple[str, Tuple[None, bytes, str]]]
URLLIB3_SUPPORTS_BLOCKSIZE = "key_blocksize" in signature(PoolKey).parameters


def _parse_token_or_url(
Expand Down Expand Up @@ -462,7 +465,9 @@ def __init__(
super().__init__(pool_connections, pool_maxsize, max_retries, pool_block)

def init_poolmanager(self, connections, maxsize, block=False, **pool_kwargs):
pool_kwargs["blocksize"] = self._blocksize
if URLLIB3_SUPPORTS_BLOCKSIZE:
# urllib3 before 2.0 doesn't support blocksize
pool_kwargs["blocksize"] = self._blocksize
return super().init_poolmanager(connections, maxsize, block, **pool_kwargs)


Expand Down

0 comments on commit d8d582f

Please sign in to comment.