mirror of
https://github.com/OpenKMIP/PyKMIP.git
synced 2025-07-21 13:04:22 +02:00
Merge pull request #56 from sedukull/propersocketclosing
Shutdown and close the socket properly
This commit is contained in:
commit
d3a5177deb
@ -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