Skip to content

Commit fbabd9f

Browse files
authored
Don't externally close connection acquired from pool (#533)
1 parent 2ac1923 commit fbabd9f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

neo4j/io/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,6 @@ def __del__(self):
275275
except OSError:
276276
pass
277277

278-
def __enter__(self):
279-
return self
280-
281-
def __exit__(self, exc_type, exc_value, traceback):
282-
self.close()
283-
284278
def route(self, database=None, bookmarks=None):
285279
""" Fetch a routing table from the server for the given
286280
`database`. For Bolt 4.3 and above, this appends a ROUTE
@@ -675,10 +669,13 @@ def fetch_routing_info(self, address, database, bookmarks, timeout):
675669
routing, or if routing support is broken or outdated
676670
"""
677671
try:
678-
with self._acquire(address, timeout) as cx:
672+
cx = self._acquire(address, timeout)
673+
try:
679674
routing_table = cx.route(
680675
database or self.workspace_config.database, bookmarks
681676
)
677+
finally:
678+
self.release(cx)
682679
except BoltRoutingError as error:
683680
# Connection was successful, but routing support is
684681
# broken. This may indicate that the routing procedure

0 commit comments

Comments
 (0)