Skip to content

Commit c9b4cc2

Browse files
committed
fix(http): resolve session method lazily in HTTP wrapper
1 parent 80b15c9 commit c9b4cc2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

rocrate_validator/utils/http.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,13 @@ def __getattr__(self, name):
232232
"""
233233
if name.upper() in {"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH"}:
234234
method = name.lower()
235-
session_method = getattr(self.session, method)
236235

237236
def _wrapped(url, *args, **kwargs):
237+
# Resolve the session method lazily, at call time, so the wrapper
238+
# always targets the current session. This keeps the wrapper valid
239+
# after the session is rebuilt in place (see ``_reconfigure``) and
240+
# avoids holding a reference to a closed session.
241+
session_method = getattr(self.session, method)
238242
response = session_method(url, *args, **kwargs)
239243
_log_cache_outcome(method.upper(), url, response, offline=self.offline)
240244
return response

0 commit comments

Comments
 (0)