82
82
AsyncClientCertificateProvider ,
83
83
ClientCertificate ,
84
84
)
85
- from ..exceptions import Neo4jError
85
+ from ..exceptions import (
86
+ DriverError ,
87
+ Neo4jError ,
88
+ )
86
89
from .auth_management import _AsyncStaticClientCertificateProvider
87
90
from .bookmark_manager import (
88
91
AsyncNeo4jBookmarkManager ,
@@ -526,13 +529,7 @@ def __del__(
526
529
527
530
def _check_state (self ):
528
531
if self ._closed :
529
- # TODO: 6.0 - raise the error
530
- # raise DriverError("Driver closed")
531
- deprecation_warn (
532
- "Using a driver after it has been closed is deprecated. "
533
- "Future versions of the driver will raise an error." ,
534
- stack_level = 3 ,
535
- )
532
+ raise DriverError ("Driver closed" )
536
533
537
534
@property
538
535
def encrypted (self ) -> bool :
@@ -584,6 +581,11 @@ def session(self, **config) -> AsyncSession:
584
581
key-word arguments.
585
582
586
583
:returns: new :class:`neo4j.AsyncSession` object
584
+
585
+ :raises DriverError: if the driver has been closed.
586
+
587
+ .. versionchanged:: 6.0
588
+ Raise :exc:`DriverError` if the driver has been closed.
587
589
"""
588
590
if "warn_notification_severity" in config :
589
591
# Would work just fine, but we don't want to introduce yet
@@ -621,9 +623,8 @@ async def close(self) -> None:
621
623
spawned from it (such as sessions or transactions) while calling
622
624
this method. Failing to do so results in unspecified behavior.
623
625
"""
624
- # TODO: 6.0 - NOOP if already closed
625
- # if self._closed:
626
- # return
626
+ if self ._closed :
627
+ return
627
628
try :
628
629
await self ._pool .close ()
629
630
except asyncio .CancelledError :
@@ -887,6 +888,8 @@ async def example(driver: neo4j.AsyncDriver) -> neo4j.Record::
887
888
:returns: the result of the ``result_transformer_``
888
889
:rtype: T
889
890
891
+ :raises DriverError: if the driver has been closed.
892
+
890
893
.. versionadded:: 5.5
891
894
892
895
.. versionchanged:: 5.8
@@ -900,6 +903,9 @@ async def example(driver: neo4j.AsyncDriver) -> neo4j.Record::
900
903
.. versionchanged:: 5.15
901
904
The ``query_`` parameter now also accepts a :class:`.Query` object
902
905
instead of only :class:`str`.
906
+
907
+ .. versionchanged:: 6.0
908
+ Raise :exc:`DriverError` if the driver has been closed.
903
909
''' # noqa: E501 example code isn't too long
904
910
self ._check_state ()
905
911
invalid_kwargs = [
@@ -1043,11 +1049,15 @@ async def verify_connectivity(self, **config) -> None:
1043
1049
:raises Exception: if the driver cannot connect to the remote.
1044
1050
Use the exception to further understand the cause of the
1045
1051
connectivity problem.
1052
+ :raises DriverError: if the driver has been closed.
1046
1053
1047
1054
.. versionchanged:: 5.0
1048
1055
The undocumented return value has been removed.
1049
1056
If you need information about the remote server, use
1050
1057
:meth:`get_server_info` instead.
1058
+
1059
+ .. versionchanged:: 6.0
1060
+ Raise :exc:`DriverError` if the driver has been closed.
1051
1061
"""
1052
1062
self ._check_state ()
1053
1063
if config :
@@ -1120,8 +1130,12 @@ async def get_server_info(self, **config) -> ServerInfo:
1120
1130
:raises Exception: if the driver cannot connect to the remote.
1121
1131
Use the exception to further understand the cause of the
1122
1132
connectivity problem.
1133
+ :raises DriverError: if the driver has been closed.
1123
1134
1124
1135
.. versionadded:: 5.0
1136
+
1137
+ .. versionchanged:: 6.0
1138
+ Raise :exc:`DriverError` if the driver has been closed.
1125
1139
"""
1126
1140
self ._check_state ()
1127
1141
if config :
@@ -1136,15 +1150,20 @@ async def supports_multi_db(self) -> bool:
1136
1150
"""
1137
1151
Check if the server or cluster supports multi-databases.
1138
1152
1139
- :returns: Returns true if the server or cluster the driver connects to
1140
- supports multi-databases, otherwise false.
1141
-
1142
1153
.. note::
1143
1154
Feature support query based solely on the Bolt protocol version.
1144
1155
The feature might still be disabled on the server side even if this
1145
1156
function return :data:`True`. It just guarantees that the driver
1146
1157
won't throw a :exc:`.ConfigurationError` when trying to use this
1147
1158
driver feature.
1159
+
1160
+ :returns: Returns true if the server or cluster the driver connects to
1161
+ supports multi-databases, otherwise false.
1162
+
1163
+ :raises DriverError: if the driver has been closed.
1164
+
1165
+ .. versionchanged:: 6.0
1166
+ Raise :exc:`DriverError` if the driver has been closed.
1148
1167
"""
1149
1168
self ._check_state ()
1150
1169
session_config = self ._read_session_config ({})
@@ -1212,10 +1231,14 @@ async def verify_authentication(
1212
1231
:raises Exception: if the driver cannot connect to the remote.
1213
1232
Use the exception to further understand the cause of the
1214
1233
connectivity problem.
1234
+ :raises DriverError: if the driver has been closed.
1215
1235
1216
1236
.. versionadded:: 5.8
1217
1237
1218
1238
.. versionchanged:: 5.14 Stabilized from experimental.
1239
+
1240
+ .. versionchanged:: 6.0
1241
+ Raise :exc:`DriverError` if the driver has been closed.
1219
1242
"""
1220
1243
self ._check_state ()
1221
1244
if config :
@@ -1245,18 +1268,23 @@ async def supports_session_auth(self) -> bool:
1245
1268
"""
1246
1269
Check if the remote supports connection re-authentication.
1247
1270
1248
- :returns: Returns true if the server or cluster the driver connects to
1249
- supports re-authentication of existing connections, otherwise
1250
- false.
1251
-
1252
1271
.. note::
1253
1272
Feature support query based solely on the Bolt protocol version.
1254
1273
The feature might still be disabled on the server side even if this
1255
1274
function return :data:`True`. It just guarantees that the driver
1256
1275
won't throw a :exc:`.ConfigurationError` when trying to use this
1257
1276
driver feature.
1258
1277
1278
+ :returns: Returns true if the server or cluster the driver connects to
1279
+ supports re-authentication of existing connections, otherwise
1280
+ false.
1281
+
1282
+ :raises DriverError: if the driver has been closed.
1283
+
1259
1284
.. versionadded:: 5.8
1285
+
1286
+ .. versionchanged:: 6.0
1287
+ Raise :exc:`DriverError` if the driver has been closed.
1260
1288
"""
1261
1289
self ._check_state ()
1262
1290
session_config = self ._read_session_config ({})
0 commit comments