Skip to content

Commit 0cb3256

Browse files
execute batch downloads in parallel worker threads
- limit downloads to 10 at a time instead of starting all at once - use more specific types for BatchDownloader#__call__ - add NEWS - calculate byte lengths with a HEAD request - add cli arg to limit download parallelism - initial implementation of pooled progress bar - pooled progress bar looks very nice - factor out receiving thread exceptions into a contextmanager - default batch parallelism to 10 - quiet all progress output from -q - don't write colored output with --no-color - make batch download parallelism 1 in html index test - write a lot more documentation for the new progress bar logic - use ProgressBarType enum everywhere
1 parent 858a515 commit 0cb3256

14 files changed

+822
-98
lines changed

news/12923.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Download concrete dists for metadata-only resolves in parallel using worker threads. Add ``--batch-download-parallelism`` CLI flag to limit parallelism. Use ``ProgressBarType`` enum class for ``--progress-bar`` choices.

src/pip/_internal/cli/cmdoptions.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from pip._vendor.packaging.utils import canonicalize_name
2323

2424
from pip._internal.cli.parser import ConfigOptionParser
25+
from pip._internal.cli.progress_bars import ProgressBarType
2526
from pip._internal.exceptions import CommandError
2627
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
2728
from pip._internal.models.format_control import FormatControl
@@ -226,11 +227,32 @@ class PipOption(Option):
226227
"--progress-bar",
227228
dest="progress_bar",
228229
type="choice",
229-
choices=["on", "off", "raw"],
230-
default="on",
231-
help="Specify whether the progress bar should be used [on, off, raw] (default: on)",
230+
choices=ProgressBarType.choices(),
231+
default=ProgressBarType.ON.value,
232+
help=(
233+
"Specify whether the progress bar should be used"
234+
f" {ProgressBarType.help_choices()} (default: %default)"
235+
),
236+
)
237+
238+
239+
batch_download_parallelism: Callable[..., Option] = partial(
240+
Option,
241+
"--batch-download-parallelism",
242+
dest="batch_download_parallelism",
243+
type="int",
244+
default=10,
245+
help=(
246+
"Maximum parallelism employed for batch downloading of metadata-only dists"
247+
" (default %default parallel requests)."
248+
" Note that more than 10 downloads may overflow the requests connection pool,"
249+
" which may affect performance."
250+
" Note also that commands such as 'install --dry-run' should avoid downloads"
251+
" entirely, and so will not be affected by this option."
252+
),
232253
)
233254

255+
234256
log: Callable[..., Option] = partial(
235257
PipOption,
236258
"--log",

0 commit comments

Comments
 (0)