Skip to content

Commit 35c0f0e

Browse files
committed
Re-introduce session config options to verify_connectivity
Amends neo4j#654
1 parent 6fe4ea7 commit 35c0f0e

File tree

4 files changed

+89
-27
lines changed

4 files changed

+89
-27
lines changed

CHANGELOG.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@
7676
It now raises a `ResultConsumedError`.
7777
- New method `Result.closed()` can be used to check for this condition if
7878
necessary.
79-
- `driver.verify_connectivity()`
80-
- All keyword arguments have been deprecated (they were experimental).
81-
They are now ignored and will be removed in a future release.
82-
- The undocumented return value has been removed. If you need information
83-
about the remote server, use `driver.get_server_info()` instead.
79+
- The undocumented return value of `driver.verify_connectivity()` has been
80+
removed. If you need information about the remote server, use
81+
`driver.get_server_info()` instead.
8482
- Transaction functions (a.k.a. managed transactions):
8583
The first argument of transaction functions is now a `ManagedTransaction`
8684
object. It behaves exactly like a regular `Transaction` object, except it

neo4j/_async/driver.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# limitations under the License.
1717

1818

19+
import warnings
20+
1921
from .._async_compat.util import AsyncUtil
2022
from .._conf import (
2123
TrustAll,
@@ -36,6 +38,8 @@
3638
from ..meta import (
3739
deprecation_warn,
3840
experimental,
41+
experimental_warn,
42+
ExperimentalWarning,
3943
unclosed_resource_warn,
4044
)
4145

@@ -310,22 +314,34 @@ async def verify_connectivity(self, **config):
310314
Even if this method raises an exception, the driver still needs to
311315
be closed via :meth:`close` to free up all resources.
312316
317+
:param config: accepts the same configuration key-word arguments as
318+
:meth:`session`.
319+
320+
.. warning::
321+
All configuration key-word arguments are experimental.
322+
They might be changed or removed in any future version without
323+
prior notice.
324+
313325
:raises DriverError: if the driver cannot connect to the remote.
314326
Use the exception to further understand the cause of the
315327
connectivity problem.
316328
317-
.. versionchanged:: 5.0 the config parameters will be removed in
318-
version 6 0. It has no effect starting with version 5.0.
329+
.. versionchanged:: 5.0
330+
The undocumented return value has been removed.
331+
If you need information about the remote server, use
332+
:meth:`get_server_info` instead.
319333
"""
320334
if config:
321-
deprecation_warn(
322-
"verify_connectivity() will not accept any configuration "
323-
"parameters starting with version 6.0."
335+
experimental_warn(
336+
"All configuration key-word arguments to "
337+
"verify_connectivity() are experimental. They might be "
338+
"changed or removed in any future version without prior "
339+
"notice."
324340
)
341+
async with self.session(**config) as session:
342+
await session._get_server_info()
325343

326-
await self.get_server_info()
327-
328-
async def get_server_info(self):
344+
async def get_server_info(self, **config):
329345
"""Get information about the connected Neo4j server.
330346
331347
Try to establish a working read connection to the remote server or a
@@ -339,6 +355,14 @@ async def get_server_info(self):
339355
Even if this method raises an exception, the driver still needs to
340356
be closed via :meth:`close` to free up all resources.
341357
358+
:param config: accepts the same configuration key-word arguments as
359+
:meth:`session`.
360+
361+
.. warning::
362+
All configuration key-word arguments are experimental.
363+
They might be changed or removed in any future version without
364+
prior notice.
365+
342366
:rtype: ServerInfo
343367
344368
:raises DriverError: if the driver cannot connect to the remote.
@@ -347,7 +371,14 @@ async def get_server_info(self):
347371
348372
.. versionadded:: 5.0
349373
"""
350-
async with self.session() as session:
374+
if config:
375+
experimental_warn(
376+
"All configuration key-word arguments to "
377+
"verify_connectivity() are experimental. They might be "
378+
"changed or removed in any future version without prior "
379+
"notice."
380+
)
381+
async with self.session(**config) as session:
351382
return await session._get_server_info()
352383

353384
@experimental("Feature support query, based on Bolt protocol version and Neo4j server version will change in the future.")

neo4j/_sync/driver.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# limitations under the License.
1717

1818

19+
import warnings
20+
1921
from .._async_compat.util import Util
2022
from .._conf import (
2123
TrustAll,
@@ -36,6 +38,8 @@
3638
from ..meta import (
3739
deprecation_warn,
3840
experimental,
41+
experimental_warn,
42+
ExperimentalWarning,
3943
unclosed_resource_warn,
4044
)
4145

@@ -310,22 +314,34 @@ def verify_connectivity(self, **config):
310314
Even if this method raises an exception, the driver still needs to
311315
be closed via :meth:`close` to free up all resources.
312316
317+
:param config: accepts the same configuration key-word arguments as
318+
:meth:`session`.
319+
320+
.. warning::
321+
All configuration key-word arguments are experimental.
322+
They might be changed or removed in any future version without
323+
prior notice.
324+
313325
:raises DriverError: if the driver cannot connect to the remote.
314326
Use the exception to further understand the cause of the
315327
connectivity problem.
316328
317-
.. versionchanged:: 5.0 the config parameters will be removed in
318-
version 6 0. It has no effect starting with version 5.0.
329+
.. versionchanged:: 5.0
330+
The undocumented return value has been removed.
331+
If you need information about the remote server, use
332+
:meth:`get_server_info` instead.
319333
"""
320334
if config:
321-
deprecation_warn(
322-
"verify_connectivity() will not accept any configuration "
323-
"parameters starting with version 6.0."
335+
experimental_warn(
336+
"All configuration key-word arguments to "
337+
"verify_connectivity() are experimental. They might be "
338+
"changed or removed in any future version without prior "
339+
"notice."
324340
)
341+
with self.session(**config) as session:
342+
session._get_server_info()
325343

326-
self.get_server_info()
327-
328-
def get_server_info(self):
344+
def get_server_info(self, **config):
329345
"""Get information about the connected Neo4j server.
330346
331347
Try to establish a working read connection to the remote server or a
@@ -339,6 +355,14 @@ def get_server_info(self):
339355
Even if this method raises an exception, the driver still needs to
340356
be closed via :meth:`close` to free up all resources.
341357
358+
:param config: accepts the same configuration key-word arguments as
359+
:meth:`session`.
360+
361+
.. warning::
362+
All configuration key-word arguments are experimental.
363+
They might be changed or removed in any future version without
364+
prior notice.
365+
342366
:rtype: ServerInfo
343367
344368
:raises DriverError: if the driver cannot connect to the remote.
@@ -347,7 +371,14 @@ def get_server_info(self):
347371
348372
.. versionadded:: 5.0
349373
"""
350-
with self.session() as session:
374+
if config:
375+
experimental_warn(
376+
"All configuration key-word arguments to "
377+
"verify_connectivity() are experimental. They might be "
378+
"changed or removed in any future version without prior "
379+
"notice."
380+
)
381+
with self.session(**config) as session:
351382
return session._get_server_info()
352383

353384
@experimental("Feature support query, based on Bolt protocol version and Neo4j server version will change in the future.")

neo4j/meta.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ class ExperimentalWarning(Warning):
7777
"""
7878

7979

80+
def experimental_warn(message, stack_level=2):
81+
warn(message, category=ExperimentalWarning, stacklevel=stack_level)
82+
83+
8084
def experimental(message):
8185
""" Decorator for tagging experimental functions and methods.
8286
@@ -92,16 +96,14 @@ def decorator(f):
9296
if asyncio.iscoroutinefunction(f):
9397
@wraps(f)
9498
async def inner(*args, **kwargs):
95-
from warnings import warn
96-
warn(message, category=ExperimentalWarning, stacklevel=2)
99+
experimental_warn(message, stack_level=3)
97100
return await f(*args, **kwargs)
98101

99102
return inner
100103
else:
101104
@wraps(f)
102105
def inner(*args, **kwargs):
103-
from warnings import warn
104-
warn(message, category=ExperimentalWarning, stacklevel=2)
106+
experimental_warn(message, stack_level=3)
105107
return f(*args, **kwargs)
106108

107109
return inner

0 commit comments

Comments
 (0)