Extensions to the transaction package.
Transaction Manager
nti.transactions.transactions.TransactionsLoop is a retryable transaction manager. It is conceptually similar to the attempts context manager provided by the transaction package itself, but much more powerful and extensible via subclasses. Features include:
Configurable commit vetos.
Extensible tests for which exceptions should be retried.
The ability to abort the transaction and bypass a potentially expensive commit when there are expected to be no side-effects.
Sleeping between retries.
Extensive logging and timing.
The TransactionLoop can be used as-is, or it can be subclassed for customization. For use in a Pyramid tween, for example, a minimal subclass might look like this:
>>> class PyramidTransactionLoop(TransactionLoop): ... def prep_for_retry(self, number, request): ... request.make_body_seekable() ... def describe_transaction(self, request): ... return request.url
Data Managers
A few data managers are provided for convenience.
The first data manager is used to put an object in a queue (something with the full and put_nowait methods) when a transaction succeeds. If the queue is full, then the transaction will not be allowed to commit:
>>> from nti.transactions.transactions import put_nowait >>> put_nowait(queue, object)
This is a special case of the ObjectDataManager, which will call one method with any arguments when a transaction commits. It can be configured to vote on whether the transaction should be allowed to commit. or not. This is useful for, say, putting an item in a Redis queue when the transaction is successful. It can be constructed directly, but the do function is a shorthand way of joining one to the current transaction:
>>> from nti.transactions.transactions import do
>>> do(print, args=("Committed"))
Changes
1.1.1 (2018-07-19)
When the TransactionLoop raises a CommitFailedError from a TypeError, it preserves the original message.
1.1.0 (2017-04-17)
Add a new ObjectDataManager that will attempt to execute after other ObjectDataManagers.
1.0.0 (2016-07-28)
Add support for Python 3.
Eliminate ZODB dependency. Instead of raising a ZODB.POSException.StorageError for unexpected TypeErrors during commit, the new class nti.transactions.interfaces.CommitFailedError is raised.
Introduce a new subclass of TransactionError, AbortFailedError that is raised when an abort fails due to a system error.
Metadata
Release files for nti.transactions 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nti.transactions-1.1.1.tar.gz | 17.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nti.transactions-1.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 34.4 kB
Release files / nti.transactions-1.1.1.tar.gz
| Download URL | nti.transactions-1.1.1.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
249f767d5d09ca4b58cd92d7c8d00cf6c1c0f26b18377ee2e8af5335ad381613
|
|
BLAKE2b-256 checksum How to use checksums |
4d1d636298d30d39b7455cc120144dc3bc761df0025ae78de85dc27e2bdcc67e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / nti.transactions-1.1.1-py2.py3-none-any.whl
| Download URL | nti.transactions-1.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e3b3a94bf02ec2783b9c428320c7d6b9841d678fef07b2e965dd8c0e3edb07f4
|
|
BLAKE2b-256 checksum How to use checksums |
2c5682f17ca739b38690a15b350f6af65955a15ce8725ca3a4f1df1dbcdf308f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |