8585 AsyncClientCertificateProvider ,
8686 ClientCertificate ,
8787)
88- from ..exceptions import Neo4jError
88+ from ..exceptions import (
89+ DriverError ,
90+ Neo4jError ,
91+ )
8992from .auth_management import _AsyncStaticClientCertificateProvider
9093from .bookmark_manager import (
9194 AsyncNeo4jBookmarkManager ,
@@ -556,13 +559,7 @@ def __del__(
556559
557560 def _check_state (self ):
558561 if self ._closed :
559- # TODO: 6.0 - raise the error
560- # raise DriverError("Driver closed")
561- deprecation_warn (
562- "Using a driver after it has been closed is deprecated. "
563- "Future versions of the driver will raise an error." ,
564- stack_level = 3 ,
565- )
562+ raise DriverError ("Driver closed" )
566563
567564 @property
568565 def encrypted (self ) -> bool :
@@ -614,6 +611,11 @@ def session(self, **config) -> AsyncSession:
614611 key-word arguments.
615612
616613 :returns: new :class:`neo4j.AsyncSession` object
614+
615+ :raises DriverError: if the driver has been closed.
616+
617+ .. versionchanged:: 6.0
618+ Raise :exc:`DriverError` if the driver has been closed.
617619 """
618620 if "warn_notification_severity" in config :
619621 # Would work just fine, but we don't want to introduce yet
@@ -651,9 +653,8 @@ async def close(self) -> None:
651653 spawned from it (such as sessions or transactions) while calling
652654 this method. Failing to do so results in unspecified behavior.
653655 """
654- # TODO: 6.0 - NOOP if already closed
655- # if self._closed:
656- # return
656+ if self ._closed :
657+ return
657658 try :
658659 await self ._pool .close ()
659660 except asyncio .CancelledError :
@@ -917,6 +918,8 @@ async def example(driver: neo4j.AsyncDriver) -> neo4j.Record::
917918 :returns: the result of the ``result_transformer_``
918919 :rtype: T
919920
921+ :raises DriverError: if the driver has been closed.
922+
920923 .. versionadded:: 5.5
921924
922925 .. versionchanged:: 5.8
@@ -930,6 +933,9 @@ async def example(driver: neo4j.AsyncDriver) -> neo4j.Record::
930933 .. versionchanged:: 5.15
931934 The ``query_`` parameter now also accepts a :class:`.Query` object
932935 instead of only :class:`str`.
936+
937+ .. versionchanged:: 6.0
938+ Raise :exc:`DriverError` if the driver has been closed.
933939 ''' # noqa: E501 example code isn't too long
934940 self ._check_state ()
935941 invalid_kwargs = [
@@ -1073,11 +1079,15 @@ async def verify_connectivity(self, **config) -> None:
10731079 :raises Exception: if the driver cannot connect to the remote.
10741080 Use the exception to further understand the cause of the
10751081 connectivity problem.
1082+ :raises DriverError: if the driver has been closed.
10761083
10771084 .. versionchanged:: 5.0
10781085 The undocumented return value has been removed.
10791086 If you need information about the remote server, use
10801087 :meth:`get_server_info` instead.
1088+
1089+ .. versionchanged:: 6.0
1090+ Raise :exc:`DriverError` if the driver has been closed.
10811091 """
10821092 self ._check_state ()
10831093 if config :
@@ -1152,8 +1162,12 @@ async def get_server_info(self, **config) -> ServerInfo:
11521162 :raises Exception: if the driver cannot connect to the remote.
11531163 Use the exception to further understand the cause of the
11541164 connectivity problem.
1165+ :raises DriverError: if the driver has been closed.
11551166
11561167 .. versionadded:: 5.0
1168+
1169+ .. versionchanged:: 6.0
1170+ Raise :exc:`DriverError` if the driver has been closed.
11571171 """
11581172 self ._check_state ()
11591173 if config :
@@ -1170,15 +1184,20 @@ async def supports_multi_db(self) -> bool:
11701184 """
11711185 Check if the server or cluster supports multi-databases.
11721186
1173- :returns: Returns true if the server or cluster the driver connects to
1174- supports multi-databases, otherwise false.
1175-
11761187 .. note::
11771188 Feature support query based solely on the Bolt protocol version.
11781189 The feature might still be disabled on the server side even if this
11791190 function return :data:`True`. It just guarantees that the driver
11801191 won't throw a :exc:`.ConfigurationError` when trying to use this
11811192 driver feature.
1193+
1194+ :returns: Returns true if the server or cluster the driver connects to
1195+ supports multi-databases, otherwise false.
1196+
1197+ :raises DriverError: if the driver has been closed.
1198+
1199+ .. versionchanged:: 6.0
1200+ Raise :exc:`DriverError` if the driver has been closed.
11821201 """
11831202 self ._check_state ()
11841203 session_config = self ._read_session_config ({})
@@ -1246,10 +1265,14 @@ async def verify_authentication(
12461265 :raises Exception: if the driver cannot connect to the remote.
12471266 Use the exception to further understand the cause of the
12481267 connectivity problem.
1268+ :raises DriverError: if the driver has been closed.
12491269
12501270 .. versionadded:: 5.8
12511271
12521272 .. versionchanged:: 5.14 Stabilized from experimental.
1273+
1274+ .. versionchanged:: 6.0
1275+ Raise :exc:`DriverError` if the driver has been closed.
12531276 """
12541277 self ._check_state ()
12551278 if config :
@@ -1281,18 +1304,23 @@ async def supports_session_auth(self) -> bool:
12811304 """
12821305 Check if the remote supports connection re-authentication.
12831306
1284- :returns: Returns true if the server or cluster the driver connects to
1285- supports re-authentication of existing connections, otherwise
1286- false.
1287-
12881307 .. note::
12891308 Feature support query based solely on the Bolt protocol version.
12901309 The feature might still be disabled on the server side even if this
12911310 function return :data:`True`. It just guarantees that the driver
12921311 won't throw a :exc:`.ConfigurationError` when trying to use this
12931312 driver feature.
12941313
1314+ :returns: Returns true if the server or cluster the driver connects to
1315+ supports re-authentication of existing connections, otherwise
1316+ false.
1317+
1318+ :raises DriverError: if the driver has been closed.
1319+
12951320 .. versionadded:: 5.8
1321+
1322+ .. versionchanged:: 6.0
1323+ Raise :exc:`DriverError` if the driver has been closed.
12961324 """
12971325 self ._check_state ()
12981326 session_config = self ._read_session_config ({})
0 commit comments