From 14df33741afc1eea9c24988a665b41087836d9ff Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Wed, 26 Mar 2025 09:09:50 +0100 Subject: [PATCH] API docs: Driver.close is not concurrency-safe --- src/neo4j/_async/driver.py | 10 +++++++++- src/neo4j/_sync/driver.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/neo4j/_async/driver.py b/src/neo4j/_async/driver.py index a54203187..a202fc590 100644 --- a/src/neo4j/_async/driver.py +++ b/src/neo4j/_async/driver.py @@ -642,7 +642,15 @@ def _prepare_session_config(cls, config_kwargs): return config_kwargs async def close(self) -> None: - """Shut down, closing any open connections in the pool.""" + """Shut down, closing any open connections in the pool. + + .. warning:: + + While the driver object is concurrency-safe, ``close`` is *not*. + Make sure you are not using the driver object or any resources + spawned from it (such as sessions or transactions) while calling + this method. Failing to do so results in unspecified behavior. + """ # TODO: 6.0 - NOOP if already closed # if self._closed: # return diff --git a/src/neo4j/_sync/driver.py b/src/neo4j/_sync/driver.py index 971f9be7f..24a61b5c8 100644 --- a/src/neo4j/_sync/driver.py +++ b/src/neo4j/_sync/driver.py @@ -641,7 +641,15 @@ def _prepare_session_config(cls, config_kwargs): return config_kwargs def close(self) -> None: - """Shut down, closing any open connections in the pool.""" + """Shut down, closing any open connections in the pool. + + .. warning:: + + While the driver object is concurrency-safe, ``close`` is *not*. + Make sure you are not using the driver object or any resources + spawned from it (such as sessions or transactions) while calling + this method. Failing to do so results in unspecified behavior. + """ # TODO: 6.0 - NOOP if already closed # if self._closed: # return