Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jd/tenacity
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8.2.3
Choose a base ref
...
head repository: jd/tenacity
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8.3.0
Choose a head ref

Commits on Aug 21, 2023

  1. Copy the full SHA
    703fe3c View commit details
  2. Add a "test" extra (#357)

    Similar to the existing "doc" extra, specify a "test" extra with the
    relevant dependencies.  Since tornado is needed for the tests, move it
    from doc to test.  This will help distributions that package tenacity to
    gather the test dependencies without the doc dependencies.
    carlwgeorge authored Aug 21, 2023
    Copy the full SHA
    a29f494 View commit details
  3. Preserve function default and kwdefault through retry decorator (#406)

    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    michael-motional and mergify[bot] authored Aug 21, 2023
    Copy the full SHA
    3100582 View commit details

Commits on Sep 15, 2023

  1. Add support for Python 3.12

    hugovk committed Sep 15, 2023
    Copy the full SHA
    09ccacc View commit details
  2. Only deploy for upstream

    hugovk committed Sep 15, 2023
    Copy the full SHA
    5c54fa0 View commit details
  3. Copy the full SHA
    8880763 View commit details
  4. Copy the full SHA
    1843b25 View commit details

Commits on Nov 14, 2023

  1. Add RetryCallState to the API docs (#419)

    * Add `RetryCallState` to the API docs
    
    User code can access the `RetryCallState` so its members should be
    documented.
    
    * :noindex: `tenacity.RetryCallState` in the README
    
    * Move `RetryCallState` docs to the API docs where hopefully they render on RTD
    rouge8 authored Nov 14, 2023
    Copy the full SHA
    f3d1909 View commit details
  2. Merge branch 'main' into add-3.12

    jd authored Nov 14, 2023
    Copy the full SHA
    21a71af View commit details
  3. Merge pull request #416 from hugovk/add-3.12

    Add support for Python 3.12 and drop EOL 3.7
    jd authored Nov 14, 2023
    Copy the full SHA
    b647dcd View commit details

Commits on Dec 3, 2023

  1. typing: update version compare to support pyright/pylance (#424)

    The current version comparison works with mypy but pyright doesn't
    handle it.
    
    Comparing against minor and major version allows it to work with pyright.
    
    related: microsoft/pyright#6639
    sbdchd authored Dec 3, 2023
    Copy the full SHA
    ebee81d View commit details

Commits on Dec 18, 2023

  1. Add ability to inspect upcoming sleep in stop funcs, and add `stop_…

    …before_delay` (#423)
    
    * Add upcoming_sleep to retry_state, and add stop_before_delay stop.
    
    * Add unit test to cover stop_before_delay.
    
    * Changelog.
    
    * Update docs for stop_before_delay.
    
    * More docs for the two stop_x_delay functions.
    
    * Add test to ensure it acts the same as stop_after_delay when upcoming sleep is 0.
    
    * Linter fixups.
    
    ---------
    
    Co-authored-by: Julien Danjou <julien@danjou.info>
    christek91 and jd authored Dec 18, 2023
    Copy the full SHA
    99e7482 View commit details

Commits on Feb 3, 2024

  1. Copy the full SHA
    0b76e7c View commit details
  2. Merge pull request #435 from jd/fix-black

    ci: replace black and flake8 by ruff
    jd authored Feb 3, 2024
    Copy the full SHA
    24b4a5c View commit details

Commits on Feb 6, 2024

  1. Incrementally build iter actions list (#434)

    * Incrementally build iter actions list
    
    * Add TypedDict for iter_state
    
    * Format with ruff
    
    * Make IterState a dataclass
    
    * Fix typing
    
    * Conditionally add slots to dataclass
    
    ---------
    
    Co-authored-by: Julien Danjou <julien@danjou.info>
    hasier and jd authored Feb 6, 2024
    Copy the full SHA
    17aefd9 View commit details

Commits on Feb 9, 2024

  1. Copy the full SHA
    2f624ba View commit details
  2. Copy the full SHA
    9eb3868 View commit details
  3. ci: simplify Mergify configuration and automerge dependabot (#443)

    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    jd and mergify[bot] authored Feb 9, 2024
    Copy the full SHA
    50065df View commit details
  4. Copy the full SHA
    9ed3e96 View commit details
  5. chore(deps): bump the github-actions group with 2 updates (#441)

    Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [actions/setup-python](https://github.com/actions/setup-python).
    
    
    Updates `actions/checkout` from 4.0.0 to 4.1.1
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v4.0.0...v4.1.1)
    
    Updates `actions/setup-python` from 4.7.0 to 5.0.0
    - [Release notes](https://github.com/actions/setup-python/releases)
    - [Commits](actions/setup-python@v4.7.0...v5.0.0)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-minor
      dependency-group: github-actions
    - dependency-name: actions/setup-python
      dependency-type: direct:production
      update-type: version-update:semver-major
      dependency-group: github-actions
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    dependabot[bot] and mergify[bot] authored Feb 9, 2024
    Copy the full SHA
    cf58675 View commit details
  6. ci(deploy): rename job (#444)

    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    jd and mergify[bot] authored Feb 9, 2024
    Copy the full SHA
    65a19f9 View commit details
  7. ci(test): remove not necessary push (#445)

    Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    jd and mergify[bot] authored Feb 9, 2024
    Copy the full SHA
    b7e4883 View commit details

Commits on Mar 2, 2024

  1. Support async actions (#437)

    * Support async actions
    
    * Fixes after main rebase
    
    * Test is_coroutine_callable
    hasier authored Mar 2, 2024
    Copy the full SHA
    bfa2c80 View commit details
  2. Copy the full SHA
    06c34a2 View commit details
  3. Copy the full SHA
    c5d2d8b View commit details

Commits on Mar 14, 2024

  1. Lazy import asyncio.sleep as it's expensive (#450)

    On my system, importing tenacity (_without tornado_) takes 35ms, and
    asyncio is singlehandedly responsible for 15ms. Some users do not ever
    use AsyncRetrying (or asyncio in their project generally) and it would
    be a shame for them to incur a unnecessary import penalty.
    
    Full disclaimer: I pursued this change primarily to reduce pip's startup
    time where asyncio was a nontrivial portion of the import timeline.
    ichard26 authored Mar 14, 2024
    Copy the full SHA
    cb15300 View commit details
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'monthly'
groups:
github-actions:
patterns:
- '*'
15 changes: 7 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -18,8 +18,6 @@ jobs:
strategy:
matrix:
include:
- python: "3.7"
tox: py37
- python: "3.8"
tox: py38
- python: "3.9"
@@ -28,22 +26,23 @@ jobs:
tox: py310
- python: "3.11"
tox: py311
- python: "3.11"
- python: "3.12"
tox: py312
- python: "3.12"
tox: pep8
- python: "3.11"
tox: black-ci
- python: "3.11"
tox: mypy
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0

- name: Setup Python 🔧
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5.0.0
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.python }}
allow-prereleases: true

- name: Build 🔧 & Test 🔍
run: |
13 changes: 7 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: Release deploy

on:
push:
tags:
release:
types:
- published

jobs:
test:
publish:
timeout-minutes: 20
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0

- name: Setup Python 🔧
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5.0.0
with:
python-version: 3.11

55 changes: 16 additions & 39 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
queue_rules:
- name: default
conditions: &CheckRuns
- "check-success=test (3.7, py37)"
merge_method: squash
queue_conditions:
- or:
- author = jd
- "#approved-reviews-by >= 1"
- author = dependabot[bot]
- or:
- files ~= ^releasenotes/notes/
- label = no-changelog
- author = dependabot[bot]
- "check-success=test (3.8, py38)"
- "check-success=test (3.9, py39)"
- "check-success=test (3.10, py310)"
- "check-success=test (3.11, py311)"
- "check-success=test (3.11, black-ci)"
- "check-success=test (3.11, pep8)"
- "check-success=test (3.11, mypy)"
- "check-success=test (3.12, py312)"
- "check-success=test (3.12, pep8)"

pull_request_rules:
- name: warn on no changelog
@@ -22,42 +29,12 @@ pull_request_rules:
⚠️ No release notes detected. Please make sure to use
[reno](https://docs.openstack.org/reno/latest/user/usage.html) to add
a changelog entry.
- name: automatic merge without changelog
conditions:
- and: *CheckRuns
- "#approved-reviews-by>=1"
- label=no-changelog
actions:
queue:
name: default
method: squash
- name: automatic merge with changelog
conditions:
- and: *CheckRuns
- "#approved-reviews-by>=1"
- files~=^releasenotes/notes/
actions:
queue:
name: default
method: squash
- name: automatic merge for jd without changelog
conditions:
- author=jd
- and: *CheckRuns
- label=no-changelog
actions:
queue:
name: default
method: squash
- name: automatic merge for jd with changelog
conditions:
- author=jd
- and: *CheckRuns
- files~=^releasenotes/notes/
- name: automatic queue
conditions: []
actions:
queue:
name: default
method: squash

- name: dismiss reviews
conditions: []
actions:
3 changes: 3 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@ Retry Main API
.. autoclass:: tenacity.tornadoweb.TornadoRetrying
:members:

.. autoclass:: tenacity.RetryCallState
:members:

After Functions
---------------

60 changes: 17 additions & 43 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
@@ -124,6 +124,16 @@ retrying stuff.
print("Stopping after 10 seconds")
raise Exception

If you're on a tight deadline, and exceeding your delay time isn't ok,
then you can give up on retries one attempt before you would exceed the delay.

.. testcode::

@retry(stop=stop_before_delay(10))
def stop_before_10_s():
print("Stopping 1 attempt before 10 seconds")
raise Exception

You can combine several stop conditions by using the `|` operator:

.. testcode::
@@ -402,43 +412,7 @@ without raising an exception (or you can re-raise or do anything really)
RetryCallState
~~~~~~~~~~~~~~

``retry_state`` argument is an object of `RetryCallState` class:

.. autoclass:: tenacity.RetryCallState

Constant attributes:

.. autoattribute:: start_time(float)
:annotation:

.. autoattribute:: retry_object(BaseRetrying)
:annotation:

.. autoattribute:: fn(callable)
:annotation:

.. autoattribute:: args(tuple)
:annotation:

.. autoattribute:: kwargs(dict)
:annotation:

Variable attributes:

.. autoattribute:: attempt_number(int)
:annotation:

.. autoattribute:: outcome(tenacity.Future or None)
:annotation:

.. autoattribute:: outcome_timestamp(float or None)
:annotation:

.. autoattribute:: idle_for(float)
:annotation:

.. autoattribute:: next_action(tenacity.RetryAction or None)
:annotation:
``retry_state`` argument is an object of :class:`~tenacity.RetryCallState` class.

Other Custom Callbacks
~~~~~~~~~~~~~~~~~~~~~~
@@ -447,33 +421,33 @@ It's also possible to define custom callbacks for other keyword arguments.

.. function:: my_stop(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation
:return: whether or not retrying should stop
:rtype: bool

.. function:: my_wait(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation
:return: number of seconds to wait before next retry
:rtype: float

.. function:: my_retry(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation
:return: whether or not retrying should continue
:rtype: bool

.. function:: my_before(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation

.. function:: my_after(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation

.. function:: my_before_sleep(retry_state)

:param RetryState retry_state: info about current retry invocation
:param RetryCallState retry_state: info about current retry invocation

Here's an example with a custom ``before_sleep`` function:

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ requires = [
]
build-backend="setuptools.build_meta"

[tool.black]
line-length = 120
safe = true
target-version = ["py37", "py38", "py39", "py310", "py311"]
[tool.ruff]
line-length = 88
indent-width = 4
target-version = "py38"

[tool.mypy]
strict = true
files = ["tenacity"]
files = ["tenacity", "tests"]
show_error_codes = true

[[tool.mypy.overrides]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
features:
- |
Added a new stop function: stop_before_delay, which will stop execution
if the next sleep time would cause overall delay to exceed the specified delay.
Useful for use cases where you have some upper bound on retry times that you must
not exceed, so returning before that timeout is preferable than returning after that timeout.
3 changes: 3 additions & 0 deletions releasenotes/notes/add-test-extra-55e869261b03e56d.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
other:
- Add a \"test\" extra
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
other:
- |
Add a Dependabot configuration submit PRs monthly (as needed)
to keep GitHub action versions updated.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Preserve __defaults__ and __kwdefaults__ through retry decorator
7 changes: 5 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -13,16 +13,16 @@ classifier =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Utilities

[options]
install_requires =
python_requires = >=3.7
python_requires = >=3.8
packages = tenacity

[options.packages.find]
@@ -35,7 +35,10 @@ tenacity = py.typed
doc =
reno
sphinx
test =
pytest
tornado>=4.5
typeguard

[tool:pytest]
filterwarnings =
Loading