Skip to content

Commit 6e5d22c

Browse files
committed
Allow client timeout to be a float
1 parent f06d805 commit 6e5d22c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pusher/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def __init__(
6060

6161
self._port = port or (443 if ssl else 80)
6262

63-
if not isinstance(timeout, six.integer_types):
64-
raise TypeError("timeout should be an integer")
63+
if not (isinstance(timeout, six.integer_types) or isinstance(timeout, float)):
64+
raise TypeError("timeout should be an integer or a float")
6565

6666
self._timeout = timeout
6767
self._json_encoder = json_encoder

pusher_tests/test_client.py

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ def test_port_should_be_number(self):
5555
self.assertRaises(TypeError, lambda: Client(
5656
app_id=u'4', key=u'key', secret=u'secret', ssl=True, port=u'400'))
5757

58+
def test_timeout_should_be_number(self):
59+
Client(app_id=u'4', key=u'key', secret=u'secret', timeout=1)
60+
Client(app_id=u'4', key=u'key', secret=u'secret', timeout=3.14)
61+
62+
self.assertRaises(TypeError, lambda: Client(
63+
app_id=u'4', key=u'key', secret=u'secret', timeout=u'1'))
64+
5865

5966
def test_port_behaviour(self):
6067
conf = Client(app_id=u'4', key=u'key', secret=u'secret', ssl=True)

0 commit comments

Comments
 (0)