Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential memory leak #25

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading