2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-16 04:38:19 +00:00

Stop waiting on logout during atexit

During atexit time, do not wait for BMCs to acknowledge logout.
This is generally a waste of time and can cause things like eventlet
to complain since atexit won't exit in a coordinated way with
greenthread context

Change-Id: I295215614ee6a20ce63f5a9ac37bbe3d9b2d9848
This commit is contained in:
Jarrod Johnson 2013-10-13 15:54:07 -04:00
parent b86e197210
commit 9dadfe0efe

View File

@ -141,6 +141,7 @@ class Session:
@classmethod
def _cleanup(cls):
for session in cls.bmc_handlers.itervalues():
session.cleaningup = True
session.logout()
@classmethod
@ -194,6 +195,7 @@ class Session:
port=623,
kg=None,
onlogon=None):
self.cleaningup = False
self.lastpayload = None
self.bmc = bmc
self.userid = userid
@ -712,6 +714,10 @@ class Session:
cls._external_handlers[handle] = (callback, handle)
else:
cls._external_handlers[handle.fileno()] = (callback, handle)
#If we don't have a socket yet, we need one for the code to behave
#correctly from this point forward
if not hasattr(Session, 'socket'):
cls._createsocket()
cls.readersockets += [handle]
@classmethod
@ -1106,6 +1112,9 @@ class Session:
return {'success': True}
callback({'success': True})
return
if self.cleaningup:
self.nowait = True
callback = False
self.raw_command(command=0x3c,
netfn=6,
data=struct.unpack("4B",
@ -1114,7 +1123,8 @@ class Session:
callback=callback,
callback_args=callback_args)
self.logged = 0
if callback is None:
self.nowait = False
if not callback:
return {'success': True}
callback({'success': True})