mirror of
https://opendev.org/x/pyghmi
synced 2025-01-14 03:37:47 +00:00
Move raising sync login exception
By raising it in the callback, another thread doing wait_for_rsp might get hit by it. Store the message and then raise in __init__ so that it lands in the correct vicinity. Change-Id: Id450a4a3f6194d95bb0eac971e0586525c49e490
This commit is contained in:
parent
b5b4e83a39
commit
4c366d2f47
@ -368,8 +368,9 @@ class Session(object):
|
||||
"""Handle synchronous callers in liue of
|
||||
a client-provided callback.
|
||||
"""
|
||||
if 'error' in response:
|
||||
raise exc.IpmiException(response['error'])
|
||||
# Be a stub, the __init__ will catch and respond to ensure response
|
||||
# is given in the same thread as was called
|
||||
return
|
||||
|
||||
def __new__(cls,
|
||||
bmc,
|
||||
@ -415,6 +416,7 @@ class Session(object):
|
||||
else:
|
||||
self.iterwaiters.append(onlogon)
|
||||
return
|
||||
self.broken = False
|
||||
self.privlevel = 4
|
||||
self.maxtimeout = 3 # be aggressive about giving up on initial packet
|
||||
self.incommand = False
|
||||
@ -465,13 +467,16 @@ class Session(object):
|
||||
if not self.async:
|
||||
while self.logging:
|
||||
Session.wait_for_rsp()
|
||||
if self.broken:
|
||||
raise exc.IpmiException(self.errormsg)
|
||||
|
||||
def _mark_broken(self):
|
||||
def _mark_broken(self, error=None):
|
||||
# since our connection has failed retries
|
||||
# deregister our keepalive facility
|
||||
Session.keepalive_sessions.pop(self, None)
|
||||
Session.waiting_sessions.pop(self, None)
|
||||
self.logging = False
|
||||
self.errormsg = error
|
||||
if self.logged:
|
||||
self.logged = 0 # mark session as busted
|
||||
self.logging = False
|
||||
@ -500,7 +505,7 @@ class Session(object):
|
||||
|
||||
def onlogon(self, parameter):
|
||||
if 'error' in parameter:
|
||||
self._mark_broken()
|
||||
self._mark_broken(parameter['error'])
|
||||
while self.logonwaiters:
|
||||
waiter = self.logonwaiters.pop()
|
||||
waiter(parameter)
|
||||
|
Loading…
x
Reference in New Issue
Block a user