8000 Adding timeout to TwilioHttpClient constructor by Kerl1310 · Pull Request #485 · twilio/twilio-python · GitHub
[go: up one dir, main page]

Skip to content

Adding timeout to TwilioHttpClient constructor #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fixing issues from code review
  • Loading branch information
Kerl1310 committed Oct 23, 2019
commit 26ed1b0c59d73190c37352269511d7f242147064
9 changes: 3 additions & 6 deletions tests/unit/http/test_http_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# -*- coding: utf-8 -*-

import six

import unittest

import mock
from mock import patch, Mock
from requests import Request
from requests import Session
from requests import Request, Session

from twilio.http.http_client import TwilioHttpClient
from twilio.http.response import Response
Expand Down Expand Up @@ -60,7 +57,7 @@ def test_request_where_method_timeout_equals_zero(self):
try:
self.client.request(
'doesnt matter', 'doesnt matter', None, None, None, None, 0, None)
except ValueError as e:
except Exception as e:
self.assertEqual(ValueError, type(e))

def test_request_where_class_timeout_manually_set(self):
Expand All @@ -82,7 +79,7 @@ def test_request_where_class_timeout_equals_zero(self):
try:
self.client.request(
'doesnt matter', 'doesnt matter')
except ValueError as e:
except Exception as e:
self.assertEqual(type(e), ValueError)

def test_request_where_class_timeout_and_method_timeout_set(self):
Expand Down
8 changes: 2 additions & 6 deletions twilio/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def __init__(self, pool_connections=True, request_hooks=None, timeout=None):
self.last_response = None
self.request_hooks = request_hooks or hooks.default_hooks()

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

Expand All @@ -51,9 +49,7 @@ def request(self, method, url, params=None, data=None, headers=None, auth=None,
:return: An http response
:rtype: A :class:`Response <twilio.rest.http.response.Response>` object
"""
if timeout is None:
pass
elif timeout <= 0:
if timeout is not None and timeout <= 0:
raise ValueError(timeout)

kwargs = {
Expand Down
0