From a56e80ac65306c8ac1261b5504b8cdf4078b97e2 Mon Sep 17 00:00:00 2001 From: Anglui <128720549+Anglui@users.noreply.github.com> Date: Mon, 16 Mar 2026 11:48:40 -0400 Subject: [PATCH] feat: add clear_session() to NBAHTTP - Introduce a public method to close and clear the internal _session. - Allows users to drop rate-limited cookies. - Prevents potential memory leaks by explicitly closing underlying TCP connections. Motivated by issues thread: https://github.com/swar/nba_api/issues/633 --- src/nba_api/library/http.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nba_api/library/http.py b/src/nba_api/library/http.py index aeac18ee..29d6b36e 100644 --- a/src/nba_api/library/http.py +++ b/src/nba_api/library/http.py @@ -78,6 +78,12 @@ def get_session(cls): def set_session(cls, session) -> None: cls._session = session + @classmethod + def clear_session(cls) -> None: + if cls._session is not None: + cls._session.close() + cls._session = None + def clean_contents(self, contents): return contents