File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
src/ansys/geometry/core/connection Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change
1
+ ensure GrpcClient class closure upon deletion
Original file line number Diff line number Diff line change 21
21
# SOFTWARE.
22
22
"""Module providing a wrapped abstraction of the gRPC stubs."""
23
23
24
+ import atexit
24
25
import logging
25
26
from pathlib import Path
26
27
import time
@@ -198,6 +199,10 @@ def __init__(
198
199
LOG .warning ("The backend version is only available after 24.1 version." )
199
200
self ._backend_version = semver .Version (24 , 1 , 0 )
200
201
202
+ # Register the close method to be called at exit - irrespectively of
203
+ # the user calling it or not...
204
+ atexit .register (self .close )
205
+
201
206
@property
202
207
def backend_type (self ) -> BackendType :
203
208
"""Backend type.
@@ -285,6 +290,10 @@ def close(self):
285
290
deleted. Furthermore, if a local Docker instance
286
291
of the Geometry service was started, it is stopped.
287
292
"""
293
+ if self ._closed is True : # pragma: no cover
294
+ self .log .debug ("Connection is already closed. Ignoring request." )
295
+ return
296
+
288
297
if self ._remote_instance :
289
298
self ._remote_instance .delete () # pragma: no cover
290
299
elif self ._docker_instance :
You can’t perform that action at this time.
0 commit comments