Skip to content

Commit

Permalink
Merge pull request #573 from ably/http-fallback-host-fix
Browse files Browse the repository at this point in the history
Fix `TypeError: '>' not supported between instances of 'float' and 'NoneType'` in http
  • Loading branch information
VeskeR authored Jan 10, 2025
2 parents f98e3d1 + 1c22c68 commit c7ca09b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ably/http/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def get_rest_hosts(self):
if host is None:
return hosts

if time.time() > self.__host_expires:
# unstore saved fallback host after fallbackRetryTimeout (RSC15f)
if self.__host_expires is not None and time.time() > self.__host_expires:
self.__host = None
self.__host_expires = None
return hosts
Expand Down
19 changes: 19 additions & 0 deletions test/unit/http_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from ably import AblyRest


def test_http_get_rest_hosts_works_when_fallback_realtime_host_is_set():
ably = AblyRest(token="foo")
ably.options.fallback_realtime_host = ably.options.get_rest_hosts()[0]
# Should not raise TypeError
hosts = ably.http.get_rest_hosts()
assert isinstance(hosts, list)
assert all(isinstance(host, str) for host in hosts)


def test_http_get_rest_hosts_works_when_fallback_realtime_host_is_not_set():
ably = AblyRest(token="foo")
ably.options.fallback_realtime_host = None
# Should not raise TypeError
hosts = ably.http.get_rest_hosts()
assert isinstance(hosts, list)
assert all(isinstance(host, str) for host in hosts)

0 comments on commit c7ca09b

Please sign in to comment.