Skip to content

Commit

Permalink
Add Python 3.8
Browse files Browse the repository at this point in the history
Also update docs.
  • Loading branch information
jamadden committed Nov 26, 2019
1 parent a6bc09f commit b90f769
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 35 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Expand Up @@ -15,8 +15,6 @@ include/
lib/
parts/

doc/_build
doc/__pycache__
doc/relstorage.*.rst
doc/changelog.rst

docs/_build
/.settings/
18 changes: 8 additions & 10 deletions .travis.yml
@@ -1,21 +1,19 @@
language: python
sudo: false
group: travis_latest
language: python
jobs:
include:
- python: 2.7 # 2.7.14 pip 9.0.1
- python: 3.6 # 3.6.3 pip 9.0.1
- python: 3.7 # 3.7.0 pip 10.0.1
dist: xenial
sudo: true
- python: pypy # 2.7.13 pip 9.0.1
- python: pypy3 # 3.5.3 pip 9.0.1
python:
- 2.7
- 3.6
- 3.7
- 3.8
- pypy
- pypy3
env:
global:
- PYTHONHASHSEED=random
- PIP_UPGRADE_STRATEGY=eager
script:
- pylint nti.transactions
- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
Expand Down
10 changes: 8 additions & 2 deletions CHANGES.rst
Expand Up @@ -3,10 +3,16 @@
Changes
=========

3.0.1 (unreleased)
3.1.0 (unreleased)
==================

- Nothing changed yet.
- Add support for Python 3.8.

- Refactor internal implementation details. Instead of importing
everything from ``nti.transactions.transactions``, more specific
modules are used to group objects by function. The old imports
continue to work. In 4.0 they will generate a deprecation warning
and in 5.0 they will be removed.


3.0.0 (2019-09-06)
Expand Down
17 changes: 9 additions & 8 deletions README.rst
Expand Up @@ -17,10 +17,10 @@

Extensions to the `transaction`_ package.

Transaction Manager
===================
Transaction Management
======================

``nti.transactions.transactions.TransactionsLoop`` is a retryable
``nti.transactions.loop.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:
Expand All @@ -34,7 +34,8 @@ more powerful and extensible via subclasses. Features include:

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::
subclass might look like this (see ``nti.transactions.pyramid_tween``
for a full-featured tween)::

>>> class PyramidTransactionLoop(TransactionLoop):
... def prep_for_retry(self, number, request):
Expand All @@ -52,7 +53,7 @@ The first data manager is used to put an object in a ``queue``
transaction succeeds. If the queue is full, then the transaction will
not be allowed to commit::

>>> from nti.transactions.transactions import put_nowait
>>> from nti.transactions.queue import put_nowait
>>> put_nowait(queue, object)

This is a special case of the ``ObjectDataManager``, which will call
Expand All @@ -63,12 +64,12 @@ 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
>>> from nti.transactions.manager import do
>>> do(print, args=("Committed"))

.. caution:: See the documentation of this object for numerous
warnings about side-effects and its interaction with the
transaction machinery. Use it with care!
warnings about side-effects and its interaction with the
transaction machinery. Use it with care!

.. _attempts: http://zodb.readthedocs.io/en/latest/transactions.html#retrying-transactions
.. _data managers: http://zodb.readthedocs.io/en/latest/transactions.html#data-managers
2 changes: 2 additions & 0 deletions docs/conf.py
Expand Up @@ -355,6 +355,8 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'https://docs.python.org/': None,
'https://transaction.readthedocs.io/en/latest/': None,
'https://perfmetrics.readthedocs.io/en/latest/': None,
}

extlinks = {'issue': ('https://github.com/NextThought/nti.transactions/issues/%s',
Expand Down
29 changes: 28 additions & 1 deletion docs/index.rst
Expand Up @@ -8,12 +8,39 @@ Contents:
changelog




nti.transactions.interfaces
===========================
.. automodule:: nti.transactions.interfaces
:members:

.. automodule:: nti.transactions.transactions

nti.transactions.manager
========================
.. automodule:: nti.transactions.manager
:members:

nti.transactions.queue
======================
.. automodule:: nti.transactions.queue
:members:

nti.transactions.loop
=====================
.. automodule:: nti.transactions.loop
:members:

nti.transactions.pyramid_tween
==============================
.. automodule:: nti.transactions.pyramid_tween
:members:

nti.transactions.transactions (deprecated)
==========================================

This module only contains backwards compatibility imports.


====================
Indices and tables
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -9,9 +9,10 @@
}

TESTS_REQUIRE = [
'zope.testrunner',
'nti.testing',
'fudge',
'nti.testing',
'pylint',
'zope.testrunner',
]

def _read(fname):
Expand Down
10 changes: 8 additions & 2 deletions src/nti/transactions/interfaces.py
Expand Up @@ -17,10 +17,16 @@ class IExtendedTransaction(ITransaction):
"""Extensions to the transaction api."""

def nti_commit():
"""Like ``commit``, but produces a perfmetrics ``transaction.commit`` metric."""
"""
Like ``commit``, but produces a :obj:`perfmetrics.Metric` ``transaction.commit``
metric.
"""

def nti_abort():
"""Like ``abort``, but produces a perfmetrics ``transaction.abort`` metric."""
"""
Like ``abort``, but produces a :obj:`perfmetrics.Metric`
``transaction.abort`` metric.
"""

class CommitFailedError(TransactionError):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/nti/transactions/loop.py
Expand Up @@ -28,7 +28,6 @@ def exc_clear():
from zope.exceptions.exceptionformatter import format_exception
from zope.exceptions.exceptionformatter import print_exception

TRACE = 5 # from ZODB.loglevels.
from .interfaces import CommitFailedError
from .interfaces import AbortFailedError
from .interfaces import ForeignTransactionError
Expand Down Expand Up @@ -130,6 +129,7 @@ def __init__(self, response, reason):

#: If not none, this should be a number that will be passed to
#: time.sleep or gevent.sleep in between retries.
#: TODO: add a backoff delay interval/multiplier between retries.
sleep = None
attempts = 10
long_commit_duration = DEFAULT_LONG_RUNNING_COMMIT_IN_SECS # seconds
Expand Down
2 changes: 2 additions & 0 deletions src/nti/transactions/transactions.py
Expand Up @@ -10,6 +10,8 @@
logger = __import__('logging').getLogger(__name__)

# BWC imports
# For 4.0 makke this produce a deprecation warning. For 5.0
# remove this.
from dm.transaction.aborthook import add_abort_hooks
from nti.transactions.loop import TransactionLoop
from nti.transactions.manager import ObjectDataManager
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
@@ -1,19 +1,19 @@
[tox]
envlist = py27,py35,py36,py37,pypy,pypy3,coverage
envlist = py27,py35,py36,py37,py38,pypy,pypy3,coverage

[testenv]
usedevelop = true
commands =
zope-testrunner --test-path=src []
deps =
.[test]
pylint nti.transactions
extras = test


[testenv:coverage]
basepython =
python2.7
python3.8
commands =
coverage run -m zope.testrunner --test-path=src
coverage report --fail-under=100
deps =
{[testenv]deps}
coverage

0 comments on commit b90f769

Please sign in to comment.