Skip to content

Confusing FullPoolError raised when passing a string timeout #5059

Closed

Description

@miguelgrinberg

Subject

In general, urllib3 validates that timeouts are ints or floats, and raises a meaningful exception when this isn't the case. Example:

r = urllib3.request("GET", "http://localhost:9200/", timeout="1")

Which raises:

ValueError: Timeout value connect was 1, but it must be an int, float or None.

But we have found one instance where instead we are seeing an obscure seemingly unrelated exception:

pool = urllib3.HTTPConnectionPool('localhost', 9200, block=True)
pool.urlopen('GET', "/", timeout="1")

Which raises:

urllib3.exceptions.FullPoolError: HTTPConnectionPool(host='localhost', port=9200): Pool reached maximum size and no more connections are allowed.

Environment

OS macOS-26.5-arm64-arm-64bit-Mach-O
Python 3.14.3
OpenSSL 3.5.5 27 Jan 2026
urllib3 2.6.3

Steps to Reproduce

import urllib3

pool = urllib3.HTTPConnectionPool('localhost', 9200, block=True)
pool.urlopen('GET', "/", timeout="1")

Expected Behavior

A ValueError is raised.

Actual Behavior

A FullPoolError is raised.

Activity

  1. sigmavirus24 commented on May 25, 2026

    @sigmavirus24
    Contributor

    We pass that to

    def _get_timeout(self, timeout: _TYPE_TIMEOUT) -> Timeout:
    """Helper that always returns a :class:`urllib3.util.Timeout`"""
    if timeout is _DEFAULT_TIMEOUT:
    return self.timeout.clone()
    if isinstance(timeout, Timeout):
    return timeout.clone()
    else:
    # User passed us an int/float. This is for backwards compatibility,
    # can be removed later
    return Timeout.from_float(timeout)
    which falls back to
    def from_float(cls, timeout: _TYPE_TIMEOUT) -> Timeout:
    """Create a new Timeout from a legacy timeout value.
    The timeout value used by httplib.py sets the same timeout on the
    connect(), and recv() socket requests. This creates a :class:`Timeout`
    object that sets the individual timeouts to the ``timeout`` value
    passed to this function.
    :param timeout: The legacy timeout value.
    :type timeout: integer, float, :attr:`urllib3.util.Timeout.DEFAULT_TIMEOUT`, or None
    :return: Timeout object
    :rtype: :class:`Timeout`
    """
    return Timeout(read=timeout, connect=timeout)
    assuming the value is a float. float("1"). Is a valid float but we don't return it here:
    float(value)
    except (TypeError, ValueError):
    raise ValueError(
    "Timeout value %s was %s, but it must be an "
    "int, float or None." % (name, value)
    ) from None
    try:
    if value <= 0:
    raise ValueError(
    "Attempted to set %s timeout to %s, but the "
    "timeout cannot be set to a value less "
    "than or equal to 0." % (name, value)
    )
    except TypeError:
    raise ValueError(
    "Timeout value %s was %s, but it must be an "
    "int, float or None." % (name, value)
    ) from None
    return value
    so I'd suggest a value = float("1") in the first try/except to solve this

  2. miguelgrinberg commented on May 26, 2026

    @miguelgrinberg
    Author

    Thanks! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions