diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -2175,19 +2175,13 @@ class Project(object): | |||
2175 | elif (gitcmd.stdout and | 2175 | elif (gitcmd.stdout and |
2176 | 'error:' in gitcmd.stdout and | 2176 | 'error:' in gitcmd.stdout and |
2177 | 'HTTP 429' in gitcmd.stdout): | 2177 | 'HTTP 429' in gitcmd.stdout): |
2178 | if not quiet: | 2178 | # Fallthru to sleep+retry logic at the bottom. |
2179 | print('429 received, sleeping: %s sec' % retry_cur_sleep, | 2179 | pass |
2180 | file=sys.stderr) | ||
2181 | time.sleep(retry_cur_sleep) | ||
2182 | retry_cur_sleep = min(retry_exp_factor * retry_cur_sleep, | ||
2183 | MAXIMUM_RETRY_SLEEP_SEC) | ||
2184 | retry_cur_sleep *= (1 - random.uniform(-RETRY_JITTER_PERCENT, | ||
2185 | RETRY_JITTER_PERCENT)) | ||
2186 | continue | ||
2187 | 2180 | ||
2188 | # If this is not last attempt, try 'git remote prune'. | 2181 | # Try to prune remote branches once in case there are conflicts. |
2189 | elif (try_n < retry_fetches - 1 and | 2182 | # For example, if the remote had refs/heads/upstream, but deleted that and |
2190 | gitcmd.stdout and | 2183 | # now has refs/heads/upstream/foo. |
2184 | elif (gitcmd.stdout and | ||
2191 | 'error:' in gitcmd.stdout and | 2185 | 'error:' in gitcmd.stdout and |
2192 | 'git remote prune' in gitcmd.stdout and | 2186 | 'git remote prune' in gitcmd.stdout and |
2193 | not prune_tried): | 2187 | not prune_tried): |
@@ -2197,6 +2191,8 @@ class Project(object): | |||
2197 | ret = prunecmd.Wait() | 2191 | ret = prunecmd.Wait() |
2198 | if ret: | 2192 | if ret: |
2199 | break | 2193 | break |
2194 | output_redir.write('retrying fetch after pruning remote branches') | ||
2195 | # Continue right away so we don't sleep as we shouldn't need to. | ||
2200 | continue | 2196 | continue |
2201 | elif current_branch_only and is_sha1 and ret == 128: | 2197 | elif current_branch_only and is_sha1 and ret == 128: |
2202 | # Exit code 128 means "couldn't find the ref you asked for"; if we're | 2198 | # Exit code 128 means "couldn't find the ref you asked for"; if we're |
@@ -2206,9 +2202,17 @@ class Project(object): | |||
2206 | elif ret < 0: | 2202 | elif ret < 0: |
2207 | # Git died with a signal, exit immediately | 2203 | # Git died with a signal, exit immediately |
2208 | break | 2204 | break |
2205 | |||
2206 | # Figure out how long to sleep before the next attempt, if there is one. | ||
2209 | if not verbose: | 2207 | if not verbose: |
2210 | print('\n%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr) | 2208 | output_redir.write('\n%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr) |
2211 | time.sleep(random.randint(30, 45)) | 2209 | if try_n < retry_fetches - 1: |
2210 | output_redir.write('sleeping %s seconds before retrying' % retry_cur_sleep) | ||
2211 | time.sleep(retry_cur_sleep) | ||
2212 | retry_cur_sleep = min(retry_exp_factor * retry_cur_sleep, | ||
2213 | MAXIMUM_RETRY_SLEEP_SEC) | ||
2214 | retry_cur_sleep *= (1 - random.uniform(-RETRY_JITTER_PERCENT, | ||
2215 | RETRY_JITTER_PERCENT)) | ||
2212 | 2216 | ||
2213 | if initial: | 2217 | if initial: |
2214 | if alt_dir: | 2218 | if alt_dir: |