diff options
author | Josip Sokcevic <sokcevic@google.com> | 2023-05-26 02:44:37 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-26 15:50:20 +0000 |
commit | 71122f941f99cea6001c143feedf34a8dbb2a2a2 (patch) | |
tree | f096a4aa5de066f39b8c787907ff6c13f370c6ec /subcmds/sync.py | |
parent | 07a4529278f4112e3a98686f01db6b05fea5f280 (diff) | |
download | git-repo-71122f941f99cea6001c143feedf34a8dbb2a2a2.tar.gz |
sync: Handle race condition when reading active jobs
It's possible that number of jobs is more than 0 when we
check length, but in the meantime number of jobs drops to
0. In that case, we are working with float(inf) which
causes other problems
Bug: 284383869
Change-Id: I5d070d1be428f8395df7fde8ca84866db46f2100
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375134
Reviewed-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Tested-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 9ae8a4ce..0e4f34c0 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -677,9 +677,6 @@ later is required to fix a server side protocol bug. | |||
677 | cls.ssh_proxy = ssh_proxy | 677 | cls.ssh_proxy = ssh_proxy |
678 | 678 | ||
679 | def _GetSyncProgressMessage(self): | 679 | def _GetSyncProgressMessage(self): |
680 | if len(self._sync_dict) == 0: | ||
681 | return None | ||
682 | |||
683 | earliest_time = float("inf") | 680 | earliest_time = float("inf") |
684 | earliest_proj = None | 681 | earliest_proj = None |
685 | for project, t in self._sync_dict.items(): | 682 | for project, t in self._sync_dict.items(): |
@@ -687,6 +684,9 @@ later is required to fix a server side protocol bug. | |||
687 | earliest_time = t | 684 | earliest_time = t |
688 | earliest_proj = project | 685 | earliest_proj = project |
689 | 686 | ||
687 | if not earliest_proj: | ||
688 | return None | ||
689 | |||
690 | elapsed = time.time() - earliest_time | 690 | elapsed = time.time() - earliest_time |
691 | jobs = jobs_str(len(self._sync_dict)) | 691 | jobs = jobs_str(len(self._sync_dict)) |
692 | return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}" | 692 | return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}" |