Skip to content

Commit

Permalink
Prevent double close in HTTP client __del__
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrm-nvidia committed Feb 5, 2024
1 parent 1dc9836 commit 6268ebb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/python/library/tritonclient/http/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def __init__(
)
self._pool = gevent.pool.Pool(max_greenlets)
self._verbose = verbose
self._closed = False

def __enter__(self):
return self
Expand All @@ -198,13 +199,15 @@ def __exit__(self, type, value, traceback):
self.close()

def __del__(self):
self.close()
if not self._closed:
self.close()

def close(self):
"""Close the client. Any future calls to server
will result in an Error.
"""
self._closed = True
self._pool.join()
self._client_stub.close()

Expand Down

0 comments on commit 6268ebb

Please sign in to comment.