Skip to content

Commit

Permalink
Merge pull request #37 from clear-street/yichen9303/sc-69042/gestalt-bug
Browse files Browse the repository at this point in the history
fix vault work memory leak
  • Loading branch information
happyyi008 authored Oct 17, 2023
2 parents e9ebcca + 4ce3aaa commit aa728e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 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,12 @@ def __init__(self,
args=(self.kubes_token_queue, ))
kubernetes_ttl_renew.start()

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

def __del__(self) -> None:
self.stop()

@retry(RuntimeError, delay=3, tries=3) # type: ignore
def get(
self,
Expand Down Expand Up @@ -159,7 +166,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 aa728e4

Please sign in to comment.