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>>
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:The
prints
should be the same, but they are not: