Skip to content

Commit

Permalink
delete session update (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellot000 authored Oct 12, 2022
1 parent 8d5c7cd commit c8309ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ def info(self):
return self._base_service.server_info

def _del_session(self):
if self._session_instance:
self._session_instance.delete()
self._session_instance = None

@property
Expand Down
11 changes: 9 additions & 2 deletions ansys/dpf/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def __init__(self, server=None):
if server_meet_version("3.0", server):
self.add_progress_system()

self._released = False

@property
def _server(self):
return self._server_weak_ref()
Expand Down Expand Up @@ -202,8 +204,13 @@ def flush_workflows(self):
"""This removes the handle on the workflow by the ``session`` """
self._api.flush_workflows(self)

def __del__(self):
def delete(self):
try:
self._deleter_func[0](self._deleter_func[1](self))
if not self._released:
self._deleter_func[0](self._deleter_func[1](self))
except:
warnings.warn(traceback.format_exc())
self._released = True

def __del__(self):
self.delete()

0 comments on commit c8309ac

Please sign in to comment.