Skip to content

Commit 6cf1859

Browse files
committed
In case request_timeout is None, use 0, where relevant
1 parent 78df3fc commit 6cf1859

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tests/core/utilities/test_http_session_manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _simulate_call(http_session_manager, uri):
7575
return _session
7676

7777

78-
@pytest.fixture
78+
@pytest.fixture(scope="function")
7979
def http_session_manager():
8080
return HTTPSessionManager()
8181

@@ -323,7 +323,6 @@ async def test_session_manager_async_cache_does_not_close_session_before_a_call_
323323
# set cache size to 1 + set future session close thread time to 0.01s
324324
http_session_manager.session_cache = SimpleCache(1)
325325
_timeout_for_testing = 0.01
326-
http_session_manager.request_timeout = _timeout_for_testing
327326

328327
async def cache_uri_and_return_session(uri):
329328
_session = await http_session_manager.async_cache_and_return_session(

web3/_utils/http_session_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def cache_and_return_session(
8686
f"{evicted_session}",
8787
)
8888
threading.Timer(
89-
request_timeout + 0.1,
89+
request_timeout or 0 + 1,
9090
self._close_evicted_sessions,
9191
args=[evicted_sessions],
9292
).start()
@@ -209,11 +209,11 @@ async def async_cache_and_return_session(
209209
# Kick off a future task, in a separate thread, to close the evicted
210210
# sessions. In the case that the cache filled very quickly and some
211211
# sessions have been evicted before their original request has been made,
212-
# we set the timer to a bit more than the `DEFAULT_TIMEOUT` for a call. This
212+
# we set the timer to a bit more than the `request_timeout` for a call. This
213213
# should make it so that any call from an evicted session can still be made
214214
# before the session is closed.
215215
threading.Timer(
216-
request_timeout.total + 0.1,
216+
request_timeout.total or 0 + 1,
217217
self._async_close_evicted_sessions,
218218
args=[evicted_sessions],
219219
).start()

0 commit comments

Comments
 (0)