jd / tenacity

Retrying library for Python
http://tenacity.readthedocs.io
Apache License 2.0
6.82k stars 283 forks source link

fix: Restore contents of retry attribute for wrapped functions #484

Closed hasier closed 5 months ago

hasier commented 5 months ago

Fixes #482

After https://github.com/jd/tenacity/pull/479 we changed the contents of the retry attribute for retry wrapped functions. However, it is useful that this attribute contains the reference to the retry object as it allows to modify its behaviour on-the-fly. Simply restoring the previous behaviour not possible, as they assume the contents of the retry attribute can be read, but recursive calls may end up overwriting the same context and make this invalid (see the discussion in #482). These changes restore the retry attribute, and update both tests and docs to make clear this is a write-only attribute and statistics should be read from the separate statistics attribute in the wrapped function.