Skip to content

Commit

Permalink
fix potential memory leak (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
meksor authored Oct 10, 2023
1 parent 0e7ea6e commit 6a95fd0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ixmp4/conf/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class ManagerConfig(Config):
template_pattern = re.compile(r"(\{env\:(\w+)\})")

def __init__(self, url: str, auth: BaseAuth, remote: bool = False) -> None:
# TODO: Find the sweet-spot for `maxsize`
# -> a trade-off between memory usage
# and load on the management service

self._cached_request = lru_cache(maxsize=128)(self._uncached_request)
self.url = url
self.auth = auth
self.client = httpx.Client(
Expand All @@ -68,11 +73,7 @@ def expand_dsn(self, dsn: str) -> str:
dsn = dsn.replace(template, val)
return dsn

# TODO: Find the sweet-spot for `maxsize`
# -> a trade-off between memory usage
# and load on the management service
@lru_cache(maxsize=128)
def _cached_request(
def _uncached_request(
self, method: str, path: str, *args, jti: str | None = None, **kwargs
):
del jti
Expand Down

0 comments on commit 6a95fd0

Please sign in to comment.