85
85
AsyncClientCertificateProvider ,
86
86
ClientCertificate ,
87
87
)
88
- from ..exceptions import Neo4jError
88
+ from ..exceptions import (
89
+ DriverError ,
90
+ Neo4jError ,
91
+ )
89
92
from .auth_management import _AsyncStaticClientCertificateProvider
90
93
from .bookmark_manager import (
91
94
AsyncNeo4jBookmarkManager ,
@@ -556,13 +559,7 @@ def __del__(
556
559
557
560
def _check_state (self ):
558
561
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" )
566
563
567
564
@property
568
565
def encrypted (self ) -> bool :
@@ -614,6 +611,11 @@ def session(self, **config) -> AsyncSession:
614
611
key-word arguments.
615
612
616
613
: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.
617
619
"""
618
620
if "warn_notification_severity" in config :
619
621
# Would work just fine, but we don't want to introduce yet
@@ -651,9 +653,8 @@ async def close(self) -> None:
651
653
spawned from it (such as sessions or transactions) while calling
652
654
this method. Failing to do so results in unspecified behavior.
653
655
"""
654
- # TODO: 6.0 - NOOP if already closed
655
- # if self._closed:
656
- # return
656
+ if self ._closed :
657
+ return
657
658
try :
658
659
await self ._pool .close ()
659
660
except asyncio .CancelledError :
@@ -917,6 +918,8 @@ async def example(driver: neo4j.AsyncDriver) -> neo4j.Record::
917
918
:returns: the result of the ``result_transformer_``
918
919
:rtype: T
919
920
921
+ :raises DriverError: if the driver has been closed.
922
+
920
923
.. versionadded:: 5.5
921
924
922
925
.. versionchanged:: 5.8
@@ -930,6 +933,9 @@ async def example(driver: neo4j.AsyncDriver) -> neo4j.Record::
930
933
.. versionchanged:: 5.15
931
934
The ``query_`` parameter now also accepts a :class:`.Query` object
932
935
instead of only :class:`str`.
936
+
937
+ .. versionchanged:: 6.0
938
+ Raise :exc:`DriverError` if the driver has been closed.
933
939
''' # noqa: E501 example code isn't too long
934
940
self ._check_state ()
935
941
invalid_kwargs = [
@@ -1073,11 +1079,15 @@ async def verify_connectivity(self, **config) -> None:
1073
1079
:raises Exception: if the driver cannot connect to the remote.
1074
1080
Use the exception to further understand the cause of the
1075
1081
connectivity problem.
1082
+ :raises DriverError: if the driver has been closed.
1076
1083
1077
1084
.. versionchanged:: 5.0
1078
1085
The undocumented return value has been removed.
1079
1086
If you need information about the remote server, use
1080
1087
:meth:`get_server_info` instead.
1088
+
1089
+ .. versionchanged:: 6.0
1090
+ Raise :exc:`DriverError` if the driver has been closed.
1081
1091
"""
1082
1092
self ._check_state ()
1083
1093
if config :
@@ -1152,8 +1162,12 @@ async def get_server_info(self, **config) -> ServerInfo:
1152
1162
:raises Exception: if the driver cannot connect to the remote.
1153
1163
Use the exception to further understand the cause of the
1154
1164
connectivity problem.
1165
+ :raises DriverError: if the driver has been closed.
1155
1166
1156
1167
.. versionadded:: 5.0
1168
+
1169
+ .. versionchanged:: 6.0
1170
+ Raise :exc:`DriverError` if the driver has been closed.
1157
1171
"""
1158
1172
self ._check_state ()
1159
1173
if config :
@@ -1170,15 +1184,20 @@ async def supports_multi_db(self) -> bool:
1170
1184
"""
1171
1185
Check if the server or cluster supports multi-databases.
1172
1186
1173
- :returns: Returns true if the server or cluster the driver connects to
1174
- supports multi-databases, otherwise false.
1175
-
1176
1187
.. note::
1177
1188
Feature support query based solely on the Bolt protocol version.
1178
1189
The feature might still be disabled on the server side even if this
1179
1190
function return :data:`True`. It just guarantees that the driver
1180
1191
won't throw a :exc:`.ConfigurationError` when trying to use this
1181
1192
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.
1182
1201
"""
1183
1202
self ._check_state ()
1184
1203
session_config = self ._read_session_config ({})
@@ -1246,10 +1265,14 @@ async def verify_authentication(
1246
1265
:raises Exception: if the driver cannot connect to the remote.
1247
1266
Use the exception to further understand the cause of the
1248
1267
connectivity problem.
1268
+ :raises DriverError: if the driver has been closed.
1249
1269
1250
1270
.. versionadded:: 5.8
1251
1271
1252
1272
.. versionchanged:: 5.14 Stabilized from experimental.
1273
+
1274
+ .. versionchanged:: 6.0
1275
+ Raise :exc:`DriverError` if the driver has been closed.
1253
1276
"""
1254
1277
self ._check_state ()
1255
1278
if config :
@@ -1281,18 +1304,23 @@ async def supports_session_auth(self) -> bool:
1281
1304
"""
1282
1305
Check if the remote supports connection re-authentication.
1283
1306
1284
- :returns: Returns true if the server or cluster the driver connects to
1285
- supports re-authentication of existing connections, otherwise
1286
- false.
1287
-
1288
1307
.. note::
1289
1308
Feature support query based solely on the Bolt protocol version.
1290
1309
The feature might still be disabled on the server side even if this
1291
1310
function return :data:`True`. It just guarantees that the driver
1292
1311
won't throw a :exc:`.ConfigurationError` when trying to use this
1293
1312
driver feature.
1294
1313
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
+
1295
1320
.. versionadded:: 5.8
1321
+
1322
+ .. versionchanged:: 6.0
1323
+ Raise :exc:`DriverError` if the driver has been closed.
1296
1324
"""
1297
1325
self ._check_state ()
1298
1326
session_config = self ._read_session_config ({})
0 commit comments