You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a callable to read max_tries and max_time was really useful to query an application config object.
Every time the function was called, the value would be read again and so it remained configurable.
After updating to version 2+, we realized that the max_tries and max_time are read from the callable once and then cached for every other usage of the function. We saw this when some unit tests that were testing that the application reloads the config correctly were broken.
This was really an use case for us and we're pinned to the previous version we had as we cannot recreate every other object that has a decorated function on every config reload and so we'd consider this a regression on this nice functionality :)
-backoff==1.10.0+backoff==2.0.1
This minimal example reproduces the problem, the output shows the difference when running in those two versions:
The output for 1.10.0 shows that the configuration is read again on every function call:
First attempt {'max_tries': 1}
Reading max_tries: {'max_tries': 1}
Calling function
Total tries 1
----
Second attempt {'max_tries': 2}
Reading max_tries: {'max_tries': 2}
Calling function
Calling function
Total tries 2
While on 2.0.1 this is only made once and then cached for every other execution:
First attempt {'max_tries': 1}
Reading max_tries: {'max_tries': 1}
Calling function
Total tries 1
----
Second attempt {'max_tries': 2}
Calling function
Total tries 1
As you can see, the second time the function already cached the max_tries and does not read it again.
The text was updated successfully, but these errors were encountered:
Hi there!
Using a callable to read
max_tries
andmax_time
was really useful to query an application config object.Every time the function was called, the value would be read again and so it remained configurable.
After updating to version 2+, we realized that the
max_tries
andmax_time
are read from the callable once and then cached for every other usage of the function. We saw this when some unit tests that were testing that the application reloads the config correctly were broken.This was really an use case for us and we're pinned to the previous version we had as we cannot recreate every other object that has a decorated function on every config reload and so we'd consider this a regression on this nice functionality :)
This minimal example reproduces the problem, the output shows the difference when running in those two versions:
The output for
1.10.0
shows that the configuration is read again on every function call:While on
2.0.1
this is only made once and then cached for every other execution:As you can see, the second time the function already cached the
max_tries
and does not read it again.The text was updated successfully, but these errors were encountered: