Skip to content

Commit b30d7d5

Browse files
committed
Use the default http timeout to close a session if None
1 parent 12c4cac commit b30d7d5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web3/_utils/http_session_manager.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def cache_and_return_session(
8686
f"{evicted_session}",
8787
)
8888
threading.Timer(
89-
request_timeout or 0 + 0.1,
89+
# If `request_timeout` is `None`, don't wait forever for the closing
90+
# session to finish the request. Instead, wait over the default timeout.
91+
request_timeout or DEFAULT_HTTP_TIMEOUT + 0.1,
9092
self._close_evicted_sessions,
9193
args=[evicted_sessions],
9294
).start()
@@ -214,7 +216,10 @@ async def async_cache_and_return_session(
214216
# is closed.
215217
asyncio.create_task(
216218
self._async_close_evicted_sessions(
217-
request_timeout.total or 0 + 0.1,
219+
# if `ClientTimeout.total` is `None`, don't wait forever for the
220+
# closing session to finish the request. Instead, use the default
221+
# timeout.
222+
request_timeout.total or DEFAULT_HTTP_TIMEOUT + 0.1,
218223
evicted_sessions,
219224
)
220225
)

0 commit comments

Comments
 (0)