Skip to content

Commit eae5e31

Browse files
committed
unregister atexit on APISession:logout
Do not SMlog information when __del__ is called and the session has already been closed. Signed-off-by: Arnaud Garcia-Fernandez <arnaud.garcia-fernandez@vates.tech>
1 parent c0658d5 commit eae5e31

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,18 @@ def login(self):
719719
raise xs_errors.XenError(msg) from exc
720720
return session
721721

722-
def logout(self, log="logout"):
722+
def _logout(self, log):
723723
if self.session is None:
724724
SMlog("APISession [{}] session is None {}".format(self.originator, log))
725725
return
726726
self.session.xenapi.session.logout()
727727
SMlog("APISession [{}] {}".format(self.originator, log))
728728
self.session = None
729729

730+
def logout(self, log="logout"):
731+
atexit.unregister(self.atexit)
732+
self._logout(log=log)
733+
730734
def __del__(self):
731735
"""Closes an API session"""
732736
atexit.unregister(self.atexit)

0 commit comments

Comments
 (0)