From 9adefa3caaaccf40c64664764f87c69b2f998ac2 Mon Sep 17 00:00:00 2001 From: Stefano Ottolenghi Date: Wed, 12 Oct 2022 09:00:08 +0200 Subject: [PATCH 1/2] Improve docstring for `timeout` param in `unit_of_work` decorator. --- neo4j/work/query.py | 1 + 1 file changed, 1 insertion(+) diff --git a/neo4j/work/query.py b/neo4j/work/query.py index 6dd6f8f36..d42b5f8fd 100644 --- a/neo4j/work/query.py +++ b/neo4j/work/query.py @@ -73,6 +73,7 @@ def count_people_tx(tx): 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. + Values higher than ``dbms.transaction.timeout`` will be ignored and will fallback 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. From d7b97a566a04478a6bb2851915e2cdbc2d6cd915 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Wed, 12 Oct 2022 10:27:48 +0200 Subject: [PATCH 2/2] Hard wrapping lines in `neo4j/work/query.py` --- neo4j/work/query.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/neo4j/work/query.py b/neo4j/work/query.py index d42b5f8fd..a69ca2a68 100644 --- a/neo4j/work/query.py +++ b/neo4j/work/query.py @@ -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:: @@ -64,16 +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. - Values higher than ``dbms.transaction.timeout`` will be ignored and will fallback to default (unless using Neo4j < 4.2). + 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.