Mercurial > public > mercurial-scm > hg-stable
diff mercurial/worker.py @ 45957:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 8f07f5a9c3de |
children | a42502e9ae6d |
line wrap: on
line diff
--- a/mercurial/worker.py Fri Nov 27 17:00:00 2020 -0500 +++ b/mercurial/worker.py Fri Nov 27 17:03:29 2020 -0500 @@ -116,8 +116,8 @@ def worthwhile(ui, costperop, nops, threadsafe=True): - '''try to determine whether the benefit of multiple processes can - outweigh the cost of starting them''' + """try to determine whether the benefit of multiple processes can + outweigh the cost of starting them""" if not threadsafe and _DISALLOW_THREAD_UNSAFE: return False @@ -131,7 +131,7 @@ def worker( ui, costperarg, func, staticargs, args, hasretval=False, threadsafe=True ): - '''run a function, possibly in parallel in multiple worker + """run a function, possibly in parallel in multiple worker processes. returns a progress iterator @@ -153,7 +153,7 @@ threadsafe - whether work items are thread safe and can be executed using a thread-based worker. Should be disabled for CPU heavy tasks that don't release the GIL. - ''' + """ enabled = ui.configbool(b'worker', b'enabled') if enabled and worthwhile(ui, costperarg, len(args), threadsafe=threadsafe): return _platformworker(ui, func, staticargs, args, hasretval) @@ -306,10 +306,10 @@ def _posixexitstatus(code): - '''convert a posix exit status into the same form returned by + """convert a posix exit status into the same form returned by os.spawnv - returns None if the process was stopped instead of exiting''' + returns None if the process was stopped instead of exiting""" if os.WIFEXITED(code): return os.WEXITSTATUS(code) elif os.WIFSIGNALED(code): @@ -423,7 +423,7 @@ def partition(lst, nslices): - '''partition a list into N slices of roughly equal size + """partition a list into N slices of roughly equal size The current strategy takes every Nth element from the input. If we ever write workers that need to preserve grouping in input @@ -450,6 +450,6 @@ What we should really be doing is have workers read filenames from a ordered queue. This preserves locality and also keeps any worker from getting more than one file out of balance. - ''' + """ for i in range(nslices): yield lst[i::nslices]