# HG changeset patch # User Jun Wu # Date 2016-11-15 02:10:40 # Node ID 9c25a1a8c685401af99688141843ae0c8a0b0d31 # Parent 7bc25549e0844de71eb16610d33f8e6adaca097b worker: change "pids" to a set There is no need to keep any order of the "pids" array. A set is more efficient for the "remove" operation. And the following patch will use that. diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -88,7 +88,7 @@ def _posixworker(ui, func, staticargs, a workers = _numworkers(ui) oldhandler = signal.getsignal(signal.SIGINT) signal.signal(signal.SIGINT, signal.SIG_IGN) - pids, problem = [], [0] + pids, problem = set(), [0] def killworkers(): # if one worker bails, there's no good reason to wait for the rest for p in pids: @@ -118,8 +118,7 @@ def _posixworker(ui, func, staticargs, a os._exit(255) # other exceptions are allowed to propagate, we rely # on lock.py's pid checks to avoid release callbacks - pids.append(pid) - pids.reverse() + pids.add(pid) os.close(wfd) fp = os.fdopen(rfd, 'rb', 0) t = threading.Thread(target=waitforworkers)