From 66f7e027a7f6cf25b25a81130ed04c558da41b1b Mon Sep 17 00:00:00 2001 From: Rouven Bauer Date: Fri, 9 Apr 2021 15:18:31 +0200 Subject: [PATCH] Don't externally close connection acquired from pool --- neo4j/io/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/neo4j/io/__init__.py b/neo4j/io/__init__.py index 5d323d45..68a44445 100644 --- a/neo4j/io/__init__.py +++ b/neo4j/io/__init__.py @@ -275,12 +275,6 @@ def __del__(self): except OSError: pass - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - def route(self, database=None, bookmarks=None): """ Fetch a routing table from the server for the given `database`. For Bolt 4.3 and above, this appends a ROUTE @@ -675,10 +669,13 @@ def fetch_routing_info(self, address, database, bookmarks, timeout): routing, or if routing support is broken or outdated """ try: - with self._acquire(address, timeout) as cx: + cx = self._acquire(address, timeout) + try: routing_table = cx.route( database or self.workspace_config.database, bookmarks ) + finally: + self.release(cx) except BoltRoutingError as error: # Connection was successful, but routing support is # broken. This may indicate that the routing procedure