Skip to content

Commit

Permalink
fix vault work memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
happyyi008 committed Oct 17, 2023
1 parent e9ebcca commit 8d21e95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion gestalt/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self,
with role and jwt string from kubernetes
"""
self._scheme: str = scheme
self._run_worker = True
self.dynamic_token_queue: Queue[Tuple[str, str, str]] = Queue()
self.kubes_token_queue: Queue[Tuple[str, str, str]] = Queue()

Expand Down Expand Up @@ -77,6 +78,9 @@ def __init__(self,
args=(self.kubes_token_queue, ))
kubernetes_ttl_renew.start()

def __del__(self) -> None:
self._run_worker = False

@retry(RuntimeError, delay=3, tries=3) # type: ignore
def get(
self,
Expand Down Expand Up @@ -159,7 +163,7 @@ def worker(self, token_queue: Queue) -> None: # type: ignore
"""

try:
while True:
while self._run_worker:
if not token_queue.empty():
token_type, token_id, token_duration = token = token_queue.get(
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def readme():
reqs_list = list(map(lambda x: x.rstrip(), reqs))

setup(name='gestalt-cfg',
version='3.3.2',
version='3.3.3',
description='A sensible configuration library for Python',
long_description=readme(),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 8d21e95

Please sign in to comment.