diff options
author | David 'Digit' Turner <digit@google.com> | 2012-09-05 10:35:06 +0200 |
---|---|---|
committer | gerrit code review <noreply-gerritcodereview@google.com> | 2012-09-05 11:38:41 -0700 |
commit | e2126652a3a1e08724a54091793bb29a79d31014 (patch) | |
tree | a931f598a6a2dcd7bc449ca7167799a18b0b493d /subcmds/sync.py | |
parent | 9a27d0111d5cf88c6b9409261707a5d7d50aaa64 (diff) | |
download | git-repo-e2126652a3a1e08724a54091793bb29a79d31014.tar.gz |
Make "repo sync -j<count>" stop properly on Ctrl-C.
The threaded 'repo sync' implementation would very often freeze the
process when interrupted by the user with Ctrl-C. The only solution
being to kill -9 the process explicitly from another terminal.
The reason for this is best explained here:
http://snakesthatbite.blogspot.fr/2010/09/cpython-threading-interrupting.html
This patch makes all helper sync threads 'daemon', which allows the
process to terminate immediately on Ctrl-C.
Note that this will forcefully kill all threads in case of interruption; this
is generally a bad thing, but:
1/ This is equivalent to calling kill -9 in another terminal, which
is the _only_ thing that can currently stop the process.
2/ There doesn't seem to be a way to tell the worker threads to
gently stop when they are in a blocking operation anyway (even
in the non-threaded case).
+ Do the same for "repo status -j<count>".
Change-Id: Ieaf45b0eacee36f35427f8edafd87415c2aa7be4
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index bfe146b6..595a35aa 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -261,6 +261,8 @@ later is required to fix a server side protocol bug. | |||
261 | pm, | 261 | pm, |
262 | sem, | 262 | sem, |
263 | err_event)) | 263 | err_event)) |
264 | # Ensure that Ctrl-C will not freeze the repo process. | ||
265 | t.daemon = True | ||
264 | threads.add(t) | 266 | threads.add(t) |
265 | t.start() | 267 | t.start() |
266 | 268 | ||