diff options
| -rw-r--r-- | project.py | 3 | ||||
| -rw-r--r-- | subcmds/forall.py | 23 |
2 files changed, 22 insertions, 4 deletions
| @@ -1909,6 +1909,9 @@ class Project(object): | |||
| 1909 | # mode, we just tried sync'ing from the upstream field; it doesn't exist, thus | 1909 | # mode, we just tried sync'ing from the upstream field; it doesn't exist, thus |
| 1910 | # abort the optimization attempt and do a full sync. | 1910 | # abort the optimization attempt and do a full sync. |
| 1911 | break | 1911 | break |
| 1912 | elif ret < 0: | ||
| 1913 | # Git died with a signal, exit immediately | ||
| 1914 | break | ||
| 1912 | time.sleep(random.randint(30, 45)) | 1915 | time.sleep(random.randint(30, 45)) |
| 1913 | 1916 | ||
| 1914 | if initial: | 1917 | if initial: |
diff --git a/subcmds/forall.py b/subcmds/forall.py index 88b23fbd..6a6d30c9 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
| @@ -20,6 +20,7 @@ import multiprocessing | |||
| 20 | import re | 20 | import re |
| 21 | import os | 21 | import os |
| 22 | import select | 22 | import select |
| 23 | import signal | ||
| 23 | import sys | 24 | import sys |
| 24 | import subprocess | 25 | import subprocess |
| 25 | 26 | ||
| @@ -207,14 +208,12 @@ without iterating through the remaining projects. | |||
| 207 | 208 | ||
| 208 | os.environ['REPO_COUNT'] = str(len(projects)) | 209 | os.environ['REPO_COUNT'] = str(len(projects)) |
| 209 | 210 | ||
| 210 | pool = multiprocessing.Pool(opt.jobs) | 211 | pool = multiprocessing.Pool(opt.jobs, InitWorker) |
| 211 | try: | 212 | try: |
| 212 | config = self.manifest.manifestProject.config | 213 | config = self.manifest.manifestProject.config |
| 213 | results_it = pool.imap( | 214 | results_it = pool.imap( |
| 214 | DoWorkWrapper, | 215 | DoWorkWrapper, |
| 215 | ([mirror, opt, cmd, shell, cnt, config, self._SerializeProject(p)] | 216 | self.ProjectArgs(projects, mirror, opt, cmd, shell, config)) |
| 216 | for cnt, p in enumerate(projects)) | ||
| 217 | ) | ||
| 218 | pool.close() | 217 | pool.close() |
| 219 | for r in results_it: | 218 | for r in results_it: |
| 220 | rc = rc or r | 219 | rc = rc or r |
| @@ -236,12 +235,28 @@ without iterating through the remaining projects. | |||
| 236 | if rc != 0: | 235 | if rc != 0: |
| 237 | sys.exit(rc) | 236 | sys.exit(rc) |
| 238 | 237 | ||
| 238 | def ProjectArgs(self, projects, mirror, opt, cmd, shell, config): | ||
| 239 | for cnt, p in enumerate(projects): | ||
| 240 | try: | ||
| 241 | project = self._SerializeProject(p) | ||
| 242 | except Exception as e: | ||
| 243 | print('Project list error: %r' % e, | ||
| 244 | file=sys.stderr) | ||
| 245 | return | ||
| 246 | except KeyboardInterrupt: | ||
| 247 | print('Project list interrupted', | ||
| 248 | file=sys.stderr) | ||
| 249 | return | ||
| 250 | yield [mirror, opt, cmd, shell, cnt, config, project] | ||
| 239 | 251 | ||
| 240 | class WorkerKeyboardInterrupt(Exception): | 252 | class WorkerKeyboardInterrupt(Exception): |
| 241 | """ Keyboard interrupt exception for worker processes. """ | 253 | """ Keyboard interrupt exception for worker processes. """ |
| 242 | pass | 254 | pass |
| 243 | 255 | ||
| 244 | 256 | ||
| 257 | def InitWorker(): | ||
| 258 | signal.signal(signal.SIGINT, signal.SIG_IGN) | ||
| 259 | |||
| 245 | def DoWorkWrapper(args): | 260 | def DoWorkWrapper(args): |
| 246 | """ A wrapper around the DoWork() method. | 261 | """ A wrapper around the DoWork() method. |
| 247 | 262 | ||
