Skip to content

Commit 6a95fd0

Browse files
authored
fix potential memory leak (#25)
1 parent 0e7ea6e commit 6a95fd0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ixmp4/conf/manager.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class ManagerConfig(Config):
4444
template_pattern = re.compile(r"(\{env\:(\w+)\})")
4545

4646
def __init__(self, url: str, auth: BaseAuth, remote: bool = False) -> None:
47+
# TODO: Find the sweet-spot for `maxsize`
48+
# -> a trade-off between memory usage
49+
# and load on the management service
50+
51+
self._cached_request = lru_cache(maxsize=128)(self._uncached_request)
4752
self.url = url
4853
self.auth = auth
4954
self.client = httpx.Client(
@@ -68,11 +73,7 @@ def expand_dsn(self, dsn: str) -> str:
6873
dsn = dsn.replace(template, val)
6974
return dsn
7075

71-
# TODO: Find the sweet-spot for `maxsize`
72-
# -> a trade-off between memory usage
73-
# and load on the management service
74-
@lru_cache(maxsize=128)
75-
def _cached_request(
76+
def _uncached_request(
7677
self, method: str, path: str, *args, jti: str | None = None, **kwargs
7778
):
7879
del jti

0 commit comments

Comments
 (0)