|
6 | 6 |
|
7 | 7 | import asyncio
|
8 | 8 | import logging
|
| 9 | +import os |
9 | 10 | import signal
|
10 | 11 | import sys
|
11 | 12 | from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor
|
|
15 | 16 |
|
16 | 17 | from mypy_extensions import mypyc_attr
|
17 | 18 |
|
18 |
| -from black import DEFAULT_WORKERS, WriteBack, format_file_in_place |
| 19 | +from black import WriteBack, format_file_in_place |
19 | 20 | from black.cache import Cache, filter_cached, read_cache, write_cache
|
20 | 21 | from black.mode import Mode
|
21 | 22 | from black.output import err
|
@@ -87,13 +88,13 @@ def reformat_many(
|
87 | 88 | maybe_install_uvloop()
|
88 | 89 |
|
89 | 90 | executor: Executor
|
90 |
| - worker_count = workers if workers is not None else DEFAULT_WORKERS |
| 91 | + if workers is None: |
| 92 | + workers = os.cpu_count() or 1 |
91 | 93 | if sys.platform == "win32":
|
92 | 94 | # Work around https://bugs.python.org/issue26903
|
93 |
| - assert worker_count is not None |
94 |
| - worker_count = min(worker_count, 60) |
| 95 | + workers = min(workers, 60) |
95 | 96 | try:
|
96 |
| - executor = ProcessPoolExecutor(max_workers=worker_count) |
| 97 | + executor = ProcessPoolExecutor(max_workers=workers) |
97 | 98 | except (ImportError, NotImplementedError, OSError):
|
98 | 99 | # we arrive here if the underlying system does not support multi-processing
|
99 | 100 | # like in AWS Lambda or Termux, in which case we gracefully fallback to
|
|
0 commit comments