diff options
| author | Gavin Mak <gavinmak@google.com> | 2026-05-11 15:56:08 -0700 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-05-12 10:41:47 -0700 |
| commit | d5037230e94e50c30698f9dd8d9404e293e23c7e (patch) | |
| tree | 3e91817d0984bdef99f2fdc4f982675de328f5c0 /command.py | |
| parent | 7cc99b24c1869d54168708a2df6e6f936c36f980 (diff) | |
| download | git-repo-d5037230e94e50c30698f9dd8d9404e293e23c7e.tar.gz | |
sync: Re-raise KeyboardInterrupt in main process
When running sync -j1, worker functions run directly in the main
process. Swallowing KeyboardInterrupt causes the loop to continue to the
next project instead of aborting.
Re-raise KeyboardInterrupt if running in the MainProcess, while
maintaining the suppression of stack traces in worker processes.
Bug: 468170157
Change-Id: I156d66bc209a265f7fa25eea0eb88737d1b51a34
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/581342
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'command.py')
| -rw-r--r-- | command.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/command.py b/command.py index e74a94fa3..ee1f68c14 100644 --- a/command.py +++ b/command.py | |||
| @@ -101,6 +101,11 @@ class Command: | |||
| 101 | def WantPager(self, _opt): | 101 | def WantPager(self, _opt): |
| 102 | return False | 102 | return False |
| 103 | 103 | ||
| 104 | @staticmethod | ||
| 105 | def is_multiprocessing_active() -> bool: | ||
| 106 | """Whether the current process is a worker in a pool.""" | ||
| 107 | return multiprocessing.current_process().name != "MainProcess" | ||
| 108 | |||
| 104 | def ReadEnvironmentOptions(self, opts): | 109 | def ReadEnvironmentOptions(self, opts): |
| 105 | """Set options from environment variables.""" | 110 | """Set options from environment variables.""" |
| 106 | 111 | ||
