mirror of https://github.com/OpenKMIP/PyKMIP.git
Fixing potential undefined variable error in client open
This change reorganizes some of the error handling code in the client open routine, preventing the generation of an undefined variable error. The net effect of the client open routine is unchanged. Fixes #199
This commit is contained in:
parent
fbb456781e
commit
aae1577e3c
|
@ -210,6 +210,8 @@ class KMIPProxy(KMIP):
|
|||
self.logger.debug("KMIPProxy suppress_ragged_eofs: {0}".format(
|
||||
self.suppress_ragged_eofs))
|
||||
|
||||
last_error = None
|
||||
|
||||
for host in self.host_list:
|
||||
self.host = host
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
@ -221,11 +223,13 @@ class KMIPProxy(KMIP):
|
|||
self.logger.error("An error occurred while connecting to "
|
||||
"appliance " + self.host)
|
||||
self.socket.close()
|
||||
last_error = e
|
||||
else:
|
||||
return
|
||||
|
||||
self.socket = None
|
||||
raise e
|
||||
if last_error:
|
||||
raise last_error
|
||||
|
||||
def _create_socket(self, sock):
|
||||
self.socket = ssl.wrap_socket(
|
||||
|
|
Loading…
Reference in New Issue