Comments (6)
Seeing something similar. Sanitized sample of our code:
@tenacity.retry(
retry=tenacity.retry_if_exception_type(MyCustomError),
stop=tenacity.stop_after_attempt(MAX_ATTEMPTS),
)
def _internal():
attempt_number = _internal.retry.statistics["attempt_number"]
...
now gives this during execution
KeyError: 'attempt_number'
from tenacity.
@hasier is this something we could avoid breaking or should I just bump to version 9?
from tenacity.
I'd say it's difficult to keep that API, as per #484 we need a new retry
instance each time the function is called to avoid overwriting the retry context on recursive calls, so that retry
object cannot be used for statistics anymore. Unless y'all can think of a different approach, maybe this does deserve a major version bump. Sorry about that.
from tenacity.
@hasier no worries, this can happen :)
I'm totally fine with the API change, but as you said this should be a major version bump.
from tenacity.
@hasier same, gotta do what you gotta do. We ended up working around it in our code by using the previous implementation if it exists or falling back to the newer one, e.g. from
attempt_number = _internal.retry.statistics["attempt_number"]
to
attempt_number = _internal.retry.statistics.get("attempt_number") or _internal.statistics.get("attempt_number")
from tenacity.
@vijaysitaram thanks for the one-liner; this helped us quickly patch our application code.
I agree with others that this should be a major version bump; we just got hit with the same error (and it hits a rare enough code path that we didn't catch it in staging).
from tenacity.
Related Issues (20)
- Any help needed for a new release? HOT 2
- attempt_number should be set to 0 HOT 1
- `tests/test_tornado.py::TestTornado - AttributeError: 'TestTornado' object has no attribute 'runTest'` w/ pytest-8.2.0 HOT 4
- Question: How to handle dynamically changing retry (think api throttling) HOT 1
- Readme formatting fell apart HOT 1
- Can't we define a retry method in the instance method?
- Disable when developing? HOT 2
- HelloGitHub Badge
- Add `__aexit__`and `__aenter__` to AttemptManager
- ImportError tenacity.asyncio HOT 15
- Bug introduced in tenacity 8.4.0: ModuleNotFoundError: No module named 'tenacity.asyncio' HOT 1
- 8.4.0 release is broken due to missing files HOT 11
- Coalesce multiple ORs into a single object
- Access all occurred exceptions in `RetryError` HOT 1
- Retry in recursive context is broken since 8.3.0 HOT 3
- 8.4.2 breaks ability to compose regular functions with `retry_base` HOT 3
- 8.4.2 breaks suggested way to overwrite tenacity behaviors on unit tests HOT 7
- `wait_random_exponential` does not respect `min` HOT 1
- 9.0.0: Unintended or missing behavior in retry_with
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tenacity.