Commit 37d51b1
authored
DBFS API 429 retries: Fix bug on computing the time until the next retry (#326)
In #319 we added 429 retries for the DBFS API.
Computing the time until the next retry as `retry_state.idle_for - time_for_last_retry` is not going to work as expected in the case where more than 1 call to functions wrapped with `retry_429` happens (e.g. in the case of `put_file`). The problem is that `time_for_last_retry` is only initialised once per databricks-cli command, while it should be initialised every time a function wrapped with `retry_429` is called, in the first attempt.
We fix this by initialising `time_for_last_retry` if `retry_state.attempt_number == 1`. This only works if the code is single-threaded, which is the case here.
Additional improvements:
* Remove unnecessary retry log, since we already have one.
* Increase max number of retries to 8, so that we have one additional retry with long delay.
* Use click.echo instead of logger, to maintain consistency with the rest of the code.
* Add clarifying note on `retry_state.idle_for`.
* Display seconds with 2 decimal places only.1 parent 0f5e5fa commit 37d51b1
2 files changed
Lines changed: 17 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | | - | |
36 | 33 | | |
37 | | - | |
38 | 34 | | |
39 | 35 | | |
40 | 36 | | |
| |||
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
48 | | - | |
| 44 | + | |
49 | 45 | | |
50 | 46 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 47 | | |
56 | 48 | | |
57 | 49 | | |
| |||
94 | 86 | | |
95 | 87 | | |
96 | 88 | | |
97 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
98 | 92 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
0 commit comments