mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Merge changes I32da12c2,Ie4a65b3e
* changes: Skip sleep and retry if git remote update exits with a signal Catch exceptions in project list generator
This commit is contained in:
commit
472ce9f5fa
@ -1909,6 +1909,9 @@ class Project(object):
|
|||||||
# mode, we just tried sync'ing from the upstream field; it doesn't exist, thus
|
# mode, we just tried sync'ing from the upstream field; it doesn't exist, thus
|
||||||
# abort the optimization attempt and do a full sync.
|
# abort the optimization attempt and do a full sync.
|
||||||
break
|
break
|
||||||
|
elif ret < 0:
|
||||||
|
# Git died with a signal, exit immediately
|
||||||
|
break
|
||||||
time.sleep(random.randint(30, 45))
|
time.sleep(random.randint(30, 45))
|
||||||
|
|
||||||
if initial:
|
if initial:
|
||||||
|
@ -20,6 +20,7 @@ import multiprocessing
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import select
|
import select
|
||||||
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@ -207,14 +208,12 @@ without iterating through the remaining projects.
|
|||||||
|
|
||||||
os.environ['REPO_COUNT'] = str(len(projects))
|
os.environ['REPO_COUNT'] = str(len(projects))
|
||||||
|
|
||||||
pool = multiprocessing.Pool(opt.jobs)
|
pool = multiprocessing.Pool(opt.jobs, InitWorker)
|
||||||
try:
|
try:
|
||||||
config = self.manifest.manifestProject.config
|
config = self.manifest.manifestProject.config
|
||||||
results_it = pool.imap(
|
results_it = pool.imap(
|
||||||
DoWorkWrapper,
|
DoWorkWrapper,
|
||||||
([mirror, opt, cmd, shell, cnt, config, self._SerializeProject(p)]
|
self.ProjectArgs(projects, mirror, opt, cmd, shell, config))
|
||||||
for cnt, p in enumerate(projects))
|
|
||||||
)
|
|
||||||
pool.close()
|
pool.close()
|
||||||
for r in results_it:
|
for r in results_it:
|
||||||
rc = rc or r
|
rc = rc or r
|
||||||
@ -236,12 +235,28 @@ without iterating through the remaining projects.
|
|||||||
if rc != 0:
|
if rc != 0:
|
||||||
sys.exit(rc)
|
sys.exit(rc)
|
||||||
|
|
||||||
|
def ProjectArgs(self, projects, mirror, opt, cmd, shell, config):
|
||||||
|
for cnt, p in enumerate(projects):
|
||||||
|
try:
|
||||||
|
project = self._SerializeProject(p)
|
||||||
|
except Exception as e:
|
||||||
|
print('Project list error: %r' % e,
|
||||||
|
file=sys.stderr)
|
||||||
|
return
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('Project list interrupted',
|
||||||
|
file=sys.stderr)
|
||||||
|
return
|
||||||
|
yield [mirror, opt, cmd, shell, cnt, config, project]
|
||||||
|
|
||||||
class WorkerKeyboardInterrupt(Exception):
|
class WorkerKeyboardInterrupt(Exception):
|
||||||
""" Keyboard interrupt exception for worker processes. """
|
""" Keyboard interrupt exception for worker processes. """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def InitWorker():
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||||
|
|
||||||
def DoWorkWrapper(args):
|
def DoWorkWrapper(args):
|
||||||
""" A wrapper around the DoWork() method.
|
""" A wrapper around the DoWork() method.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user