# HG changeset patch # User Martin von Zweigbergk # Date 2020-08-13 17:37:25 # Node ID 26eb62bd0550396f4192b1a63dc96088ffc4bc58 # Parent 8c466bcb087960e126ca699b59337e6cf5c30fe6 posixworker: avoid creating workers that end up getting no work If `workers` (the detected or configured number of CPUs) is greater than the number of work items, then some of the workers end up getting 0 work items. Let's not create such workers. Differential Revision: https://phab.mercurial-scm.org/D8927 diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -211,7 +211,7 @@ def _posixworker(ui, func, staticargs, a parentpid = os.getpid() pipes = [] retval = {} - for pargs in partition(args, workers): + for pargs in partition(args, min(workers, len(args))): # Every worker gets its own pipe to send results on, so we don't have to # implement atomic writes larger than PIPE_BUF. Each forked process has # its own pipe's descriptors in the local variables, and the parent