diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index caba4a8e..cfa34944 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -496,14 +496,15 @@ class Session(object): if self.logged: self.logged = 0 # mark session as busted self.logging = False - for ka in list(self._customkeepalives): + if self._customkeepalives: + for ka in list(self._customkeepalives): # Be thorough and notify parties through their custom # keepalives. In practice, this *should* be the same, but # if a code somehow makes duplicate SOL handlers, # this would notify all the handlers rather than just the # last one to take ownership - self._customkeepalives[ka][1]( - {'error': 'Session Disconnected'}) + self._customkeepalives[ka][1]( + {'error': 'Session Disconnected'}) self._customkeepalives = None if not self.broken: self.socketpool[self.socket] -= 1