Closed mesozoic closed 1 year ago
It seems this code only works with urllib3 >= 1.26, when they changed the signature of the Retry
class, whereas the minimum version we test against is 1.25.11. Given that 1.26.0 was released in 2020, I'm going to suggest we bump up the urllib3 dependency for this package instead of trying to remain backwards-compatible.
Merging #272 (9f5edbc) into main (9632b6e) will decrease coverage by
0.18%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## main #272 +/- ##
==========================================
- Coverage 94.64% 94.46% -0.18%
==========================================
Files 15 15
Lines 765 759 -6
==========================================
- Hits 724 717 -7
- Misses 41 42 +1
Impacted Files | Coverage Δ | |
---|---|---|
pyairtable/api/table.py | 98.00% <ø> (-0.10%) |
:arrow_down: |
pyairtable/api/api.py | 98.50% <100.00%> (-1.50%) |
:arrow_down: |
pyairtable/api/retrying.py | 100.00% <100.00%> (ø) |
I added an integration test that does (more or less) what the batch above does; it spawns 25 threads and makes multiple calls to batch_create
from each of them. Without the default retry strategy, the test fails. With it, the test passes in ~14 seconds. Better to be confident we won't regress this in the future.
This implements a default retry strategy which will retry 429 (too many requests) up to five times before giving up. This seems like a sensible default, and it is similar to the behavior of the official Airtable.js library. The brief testing I've done suggests that removing
time.sleep
and replacing with retries does speed up large batch operations.Given this code...
...I got this output:
I'd considered retrying 500s by default, but I think that is probably inadvisable given a 500 might indicate a request was partially fulfilled. It should be left to the implementer to decide whether to retry an operation in that situation or not.
This does not add any new tests. I considered adding something like the above as an integration test, but it would add several seconds to each test run and I'm not clear on what sort of regressions we'd actually be guarding against.
This branch closes #218