mirror of
https://github.com/OpenKMIP/PyKMIP.git
synced 2025-07-28 08:24:04 +02:00
Shutdown and close the socket properly.
Calling close in destructor, helps in case default close() is not called by consumers.
This commit is contained in:
parent
dfb6594a52
commit
4a0b2c4c57
@ -96,6 +96,7 @@ class KMIPProxy(KMIP):
|
|||||||
self.authentication_suites = [
|
self.authentication_suites = [
|
||||||
AuthenticationSuite.BASIC,
|
AuthenticationSuite.BASIC,
|
||||||
AuthenticationSuite.TLS12]
|
AuthenticationSuite.TLS12]
|
||||||
|
self.socket = None
|
||||||
|
|
||||||
def get_supported_conformance_clauses(self):
|
def get_supported_conformance_clauses(self):
|
||||||
"""
|
"""
|
||||||
@ -225,8 +226,16 @@ class KMIPProxy(KMIP):
|
|||||||
self.logger.error("timeout occurred while connecting to appliance")
|
self.logger.error("timeout occurred while connecting to appliance")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
# Close the socket properly, helpful in case close() is not called.
|
||||||
|
self.close()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.socket.shutdown(socket.SHUT_RDWR)
|
# Shutdown and close the socket.
|
||||||
|
if self.socket:
|
||||||
|
self.socket.shutdown(socket.SHUT_RDWR)
|
||||||
|
self.socket.close()
|
||||||
|
self.socket = None
|
||||||
|
|
||||||
def create(self, object_type, template_attribute, credential=None):
|
def create(self, object_type, template_attribute, credential=None):
|
||||||
object_type = attr.ObjectType(object_type)
|
object_type = attr.ObjectType(object_type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user