Skip to content

Commit 76a034c

Browse files
Improve docstring for timeout param in unit_of_work decorator. (#827)
Also hard-wrapping lines in `neo4j/work/query.py` Co-authored-by: Robsdedude <[email protected]>
1 parent 8698f30 commit 76a034c

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

neo4j/work/query.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def __str__(self) -> str:
5050
def unit_of_work(
5151
metadata: t.Dict[str, t.Any] = None, timeout: float = None
5252
) -> t.Callable[[_T], _T]:
53-
"""This function is a decorator for transaction functions that allows extra control over how the transaction is carried out.
53+
"""Decorator giving extra control over transaction function configuration.
54+
55+
This function is a decorator for transaction functions that allows extra
56+
control over how the transaction is carried out.
5457
5558
For example, a timeout may be applied::
5659
@@ -64,15 +67,24 @@ def count_people_tx(tx):
6467
6568
:param metadata:
6669
a dictionary with metadata.
67-
Specified metadata will be attached to the executing transaction and visible in the output of ``dbms.listQueries`` and ``dbms.listTransactions`` procedures.
70+
Specified metadata will be attached to the executing transaction and
71+
visible in the output of ``dbms.listQueries`` and
72+
``dbms.listTransactions`` procedures.
6873
It will also get logged to the ``query.log``.
69-
This functionality makes it easier to tag transactions and is equivalent to ``dbms.setTXMetaData`` procedure, see https://neo4j.com/docs/operations-manual/current/reference/procedures/ for procedure reference.
74+
This functionality makes it easier to tag transactions and is
75+
equivalent to ``dbms.setTXMetaData`` procedure, see
76+
https://neo4j.com/docs/operations-manual/current/reference/procedures/
77+
for procedure reference.
7078
7179
:param timeout:
7280
the transaction timeout in seconds.
73-
Transactions that execute longer than the configured timeout will be terminated by the database.
81+
Transactions that execute longer than the configured timeout will be
82+
terminated by the database.
7483
This functionality allows to limit query/transaction execution time.
75-
Specified timeout overrides the default timeout configured in the database using ``dbms.transaction.timeout`` setting.
84+
Specified timeout overrides the default timeout configured in the
85+
database using ``dbms.transaction.timeout`` setting.
86+
Values higher than ``dbms.transaction.timeout`` will be ignored and
87+
will fall back to default (unless using Neo4j < 4.2).
7688
Value should not represent a negative duration.
7789
A zero duration will make the transaction execute indefinitely.
7890
None will use the default timeout configured in the database.

0 commit comments

Comments
 (0)