Skip to content
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

method.retry_with unbids it from its class instance #453

Open
jakub-krysl-ipf opened this issue Apr 3, 2024 · 0 comments
Open

method.retry_with unbids it from its class instance #453

jakub-krysl-ipf opened this issue Apr 3, 2024 · 0 comments

Comments

@jakub-krysl-ipf
Copy link

Hi,

If you have method wrapped in @retry() and want to change the params of the retry elsewhere using .retry_with(), you need to provide the class instance again. Here is a simple reproducer:

import tenacity
from datetime import datetime


class TestClass:
    @tenacity.retry(wait=tenacity.wait_fixed(5), stop=tenacity.stop_after_delay(10))
    def test(self, a):
        print(datetime.now(), a)
        raise Exception()


t = TestClass()

print(t.test.retry_with(wait=tenacity.wait_fixed(2), stop=tenacity.stop_after_delay(10)))
print(t.test)

# Usage of original retry is simple, does not need to provide "t" instance at all
t.test("OK")
# This should not need class instance "t" again
t.test.retry_with(wait=tenacity.wait_fixed(1), stop=tenacity.stop_after_delay(3))(t, a="OK")

The prints should be the same, but they are not:

<function TestClass.test at 0x7fa403015760>
<bound method TestClass.test of <__main__.TestClass object at 0x7fa4025c0990>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant