mirror of
https://github.com/openkmip/pykmip
synced 2026-01-03 17:13:19 +00:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user