don't run more than 61 workers on Windows (#838)
This commit is contained in:
parent
3b2297f6fd
commit
14cbf737df
@ -986,6 +986,8 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
|
|||||||
|
|
||||||
### 19.5b0
|
### 19.5b0
|
||||||
|
|
||||||
|
* don't crash when run on a Windows machine with more than 61 cores (#838)
|
||||||
|
|
||||||
* remove unnecessary parentheses around `yield` expressions (#834)
|
* remove unnecessary parentheses around `yield` expressions (#834)
|
||||||
|
|
||||||
* add parentheses around long tuples in unpacking assignments (#832)
|
* add parentheses around long tuples in unpacking assignments (#832)
|
||||||
|
48
black.py
48
black.py
@ -440,22 +440,10 @@ def main(
|
|||||||
report=report,
|
report=report,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
loop = asyncio.get_event_loop()
|
reformat_many(
|
||||||
executor = ProcessPoolExecutor(max_workers=os.cpu_count())
|
sources=sources, fast=fast, write_back=write_back, mode=mode, report=report
|
||||||
try:
|
|
||||||
loop.run_until_complete(
|
|
||||||
schedule_formatting(
|
|
||||||
sources=sources,
|
|
||||||
fast=fast,
|
|
||||||
write_back=write_back,
|
|
||||||
mode=mode,
|
|
||||||
report=report,
|
|
||||||
loop=loop,
|
|
||||||
executor=executor,
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
finally:
|
|
||||||
shutdown(loop)
|
|
||||||
if verbose or not quiet:
|
if verbose or not quiet:
|
||||||
bang = "💥 💔 💥" if report.return_code else "✨ 🍰 ✨"
|
bang = "💥 💔 💥" if report.return_code else "✨ 🍰 ✨"
|
||||||
out(f"All done! {bang}")
|
out(f"All done! {bang}")
|
||||||
@ -497,6 +485,36 @@ def reformat_one(
|
|||||||
report.failed(src, str(exc))
|
report.failed(src, str(exc))
|
||||||
|
|
||||||
|
|
||||||
|
def reformat_many(
|
||||||
|
sources: Set[Path],
|
||||||
|
fast: bool,
|
||||||
|
write_back: WriteBack,
|
||||||
|
mode: FileMode,
|
||||||
|
report: "Report",
|
||||||
|
) -> None:
|
||||||
|
"""Reformat multiple files using a ProcessPoolExecutor."""
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
worker_count = os.cpu_count()
|
||||||
|
if sys.platform == "win32":
|
||||||
|
# Work around https://bugs.python.org/issue26903
|
||||||
|
worker_count = min(worker_count, 61)
|
||||||
|
executor = ProcessPoolExecutor(max_workers=worker_count)
|
||||||
|
try:
|
||||||
|
loop.run_until_complete(
|
||||||
|
schedule_formatting(
|
||||||
|
sources=sources,
|
||||||
|
fast=fast,
|
||||||
|
write_back=write_back,
|
||||||
|
mode=mode,
|
||||||
|
report=report,
|
||||||
|
loop=loop,
|
||||||
|
executor=executor,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
shutdown(loop)
|
||||||
|
|
||||||
|
|
||||||
async def schedule_formatting(
|
async def schedule_formatting(
|
||||||
sources: Set[Path],
|
sources: Set[Path],
|
||||||
fast: bool,
|
fast: bool,
|
||||||
|
Loading…
Reference in New Issue
Block a user