Skip to content

Commit c7ca09b

Browse files
authored
Merge pull request #573 from ably/http-fallback-host-fix
Fix `TypeError: '>' not supported between instances of 'float' and 'NoneType'` in http
2 parents f98e3d1 + 1c22c68 commit c7ca09b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ably/http/http.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def get_rest_hosts(self):
146146
if host is None:
147147
return hosts
148148

149-
if time.time() > self.__host_expires:
149+
# unstore saved fallback host after fallbackRetryTimeout (RSC15f)
150+
if self.__host_expires is not None and time.time() > self.__host_expires:
150151
self.__host = None
151152
self.__host_expires = None
152153
return hosts

test/unit/http_test.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from ably import AblyRest
2+
3+
4+
def test_http_get_rest_hosts_works_when_fallback_realtime_host_is_set():
5+
ably = AblyRest(token="foo")
6+
ably.options.fallback_realtime_host = ably.options.get_rest_hosts()[0]
7+
# Should not raise TypeError
8+
hosts = ably.http.get_rest_hosts()
9+
assert isinstance(hosts, list)
10+
assert all(isinstance(host, str) for host in hosts)
11+
12+
13+
def test_http_get_rest_hosts_works_when_fallback_realtime_host_is_not_set():
14+
ably = AblyRest(token="foo")
15+
ably.options.fallback_realtime_host = None
16+
# Should not raise TypeError
17+
hosts = ably.http.get_rest_hosts()
18+
assert isinstance(hosts, list)
19+
assert all(isinstance(host, str) for host in hosts)

0 commit comments

Comments
 (0)