From 2d5eebebd852609d4d7b898f016f36f03cbd93a3 Mon Sep 17 00:00:00 2001 From: Jarrod Johnon Date: Tue, 16 Sep 2014 09:46:40 -0400 Subject: [PATCH] Handle custom keepalive modifications on the fly It is possible for activity under 'raw_command' to modify custom keepalive registry. Tolerate the structure changing in the loop gracefully. Change-Id: I99c99b52718dff518c303819e7a24085cc6fb97a --- pyghmi/ipmi/private/session.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index f8a4f444..1db4fdd4 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -1007,7 +1007,15 @@ class Session(object): else: kaids = list(self._customkeepalives.keys()) for keepalive in kaids: - cmd, callback = self._customkeepalives[keepalive] + try: + cmd, callback = self._customkeepalives[keepalive] + except TypeError: + # raw_command made customkeepalives None + break + except KeyError: + # raw command ultimately caused a keepalive to + # deregister + continue callback(self.raw_command(**cmd)) except exc.IpmiException: self._mark_broken()