Skip to content

Improve docstring for timeout param in unit_of_work decorator. #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions neo4j/work/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def __str__(self) -> str:
def unit_of_work(
metadata: t.Dict[str, t.Any] = None, timeout: float = None
) -> t.Callable[[_T], _T]:
"""This function is a decorator for transaction functions that allows extra control over how the transaction is carried out.
"""Decorator giving extra control over transaction function configuration.

This function is a decorator for transaction functions that allows extra
control over how the transaction is carried out.

For example, a timeout may be applied::

Expand All @@ -64,15 +67,24 @@ def count_people_tx(tx):

:param metadata:
a dictionary with metadata.
Specified metadata will be attached to the executing transaction and visible in the output of ``dbms.listQueries`` and ``dbms.listTransactions`` procedures.
Specified metadata will be attached to the executing transaction and
visible in the output of ``dbms.listQueries`` and
``dbms.listTransactions`` procedures.
It will also get logged to the ``query.log``.
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.
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.

:param timeout:
the transaction timeout in seconds.
Transactions that execute longer than the configured timeout will be terminated by the database.
Transactions that execute longer than the configured timeout will be
terminated by the database.
This functionality allows to limit query/transaction execution time.
Specified timeout overrides the default timeout configured in the database using ``dbms.transaction.timeout`` setting.
Specified timeout overrides the default timeout configured in the
database using ``dbms.transaction.timeout`` setting.
Values higher than ``dbms.transaction.timeout`` will be ignored and
will fall back to default (unless using Neo4j < 4.2).
Value should not represent a negative duration.
A zero duration will make the transaction execute indefinitely.
None will use the default timeout configured in the database.
Expand Down