diff --git a/neo4j/io/__init__.py b/neo4j/io/__init__.py index 4b6a2b93..e4f7059d 100644 --- a/neo4j/io/__init__.py +++ b/neo4j/io/__init__.py @@ -335,7 +335,7 @@ def open(cls, address, *, auth=None, timeout=None, routing_context=None, **pool_ from neo4j.io._bolt4 import Bolt4x3 connection = Bolt4x3(address, s, pool_config.max_connection_lifetime, auth=auth, user_agent=pool_config.user_agent, routing_context=routing_context) else: - log.debug("[#%04X] S: ", s.getpeername()[1]) + log.debug("[#%04X] S: ", s.getsockname()[1]) _close_socket(s) supported_versions = Bolt.protocol_handlers().keys() @@ -540,7 +540,7 @@ def _set_defunct(self, message, error=None, silent=False): direct_driver = isinstance(self.pool, BoltPool) if error: - log.error(str(error)) + log.debug("[#%04X] %s", self.socket.getsockname()[1], error) log.error(message) # We were attempting to receive data but the connection # has unexpectedly terminated. So, we need to close the @@ -703,7 +703,9 @@ def release(self, *connections): """ with self.lock: for connection in connections: - if not connection.is_reset: + if not (connection.is_reset + or connection.defunct() + or connection.closed()): try: connection.reset() except (Neo4jError, DriverError, BoltError) as e: