Make AsyncRetrying callable (as Retrying class)#253
Conversation
Not entirely sure, but I would say that this line should be added so that it follows the same structure that `Retrying` class.
jd
left a comment
There was a problem hiding this comment.
Does it make sense to have that BaseRetrying instead?
We should add test if it makes sense.
|
To give you more context. I'm using async def task():
pass
retrying = AsyncRetrying(...)
await retrying.call(task)But the sync version would be different (according to the documentation): def task():
pass
retrying = Retrying(...)
retrying(task)Note that Let me know if you think this makes sense. If this is the case I'll try to implement a unit test. |
|
Yeah makes sense to me. I think we assumed it was available on |
@jd I've been thinking about it. My proposal would be to just directly override the class AsyncRetrying(BaseRetrying):
async def call(...):
pass
__call__ = callWe would have: class AsyncRetrying(BaseRetrying):
async def call(...):
passThe same for This would also require changing the line https://github.com/jd/tenacity/blob/master/tenacity/__init__.py#L329 for: What do you think? |
|
@jd I've been updating the proposal.
Let me know what do you think. |
|
Thank you @jd for the review. |
…Tests fail Tests in TestInvokeViaLegacyCallMethod begin to fail. This reverts commit 8ee3d27
* Temporarily Revert "Make AsyncRetrying callable (as Retrying class) (#253)" This reverts commit 78a462e * Add test coverage for __call__() interface: Tests passing * Re-apply "Make AsyncRetrying callable (as Retrying class) (#253)": Tests fail Tests in TestInvokeViaLegacyCallMethod begin to fail. This reverts commit 8ee3d27 * Fix Retrying.call() to invoke __call__ correctly and return result * Fix Retrying.call() to raise DeprecationWarning * pep8
Since tenacity 6.0.0, `tenacity.Retrying.call` is deprecated and generates warning messages. Instead one should be calling the `Retrying` instance itself: `retrying()`. jd/tenacity#253 This new recommended behavior was also previously supported (no breaking change).
Not entirely sure, but I would say that this line should be added so that it follows the same structure that
Retryingclass.