Handle KeyboardInterrupt during repo sync

If interrupt signal is sent to repo process while sync is running, repo
prints stack trace for each concurrent job that is currently running
with no useful information.

Instead, this change captures KeyboardInterrupt in each process and
prints one line about current project that is being processed.

Change-Id: Ieca760ed862341939396b8186ae04128d769cd56
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/357135
Reviewed-by: Joanna Wang <jojwang@google.com>
Tested-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
Josip Sokcevic 2023-02-01 14:52:27 -08:00
parent dccf38e34f
commit 69427da8c9

View File

@ -498,6 +498,8 @@ later is required to fix a server side protocol bug.
print('error: Cannot fetch %s from %s' print('error: Cannot fetch %s from %s'
% (project.name, project.remote.url), % (project.name, project.remote.url),
file=sys.stderr) file=sys.stderr)
except KeyboardInterrupt as e:
print(f'Keyboard interrupt while processing {project.name}')
except GitError as e: except GitError as e:
print('error.GitError: Cannot fetch %s' % str(e), file=sys.stderr) print('error.GitError: Cannot fetch %s' % str(e), file=sys.stderr)
except Exception as e: except Exception as e: