Skip to content

[BUG] AsyncTwilioHttpClient.request does not use self.timeout #925

Description

@bokrosbalint

Describe the bug

AsyncTwilioHttpClient.request never falls back to self.timeout if timeout is None

Code snippet

        if timeout is not None and timeout <= 0:
            raise ValueError(timeout)

        basic_auth = None
        if auth is not None:
            basic_auth = BasicAuth(login=auth[0], password=auth[1])

        kwargs = {
            "method": method.upper(),
            "url": url,
            "params": params,
            "data": data,
            "headers": headers,
            "auth": basic_auth,
            "timeout": timeout,
            "allow_redirects": allow_redirects,
        }

        self.log_request(kwargs)
        self._test_only_last_response = None

        temp = False
        session = None
        if self.session:
            session = self.session
        else:
            session = ClientSession()
            temp = True
        self._test_only_last_request = TwilioRequest(**kwargs)
        response = await session.request(**kwargs)

Actual behavior

response is passed "timeout": None in kwargs instead of "timeout": self.timeout when no timeout argument is passed

Expected behavior

response is passed "timeout": self.timeout in kwargs when no timeout argument is passed, this is what (sync) TwilioHttpClient does:

        if timeout is None:
            timeout = self.timeout
        elif timeout <= 0:
            raise ValueError(timeout)

twilio-python version

9.10.9

Python version

3

Logs or error messages

No response

Additional context

No response

Activity

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

    type: bugbug in the library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions