Skip to content

Commit 3008a61

Browse files
committed
update docstrings
1 parent ec43625 commit 3008a61

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/pip/_internal/network/download.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ def _http_get_download(session: PipSession, link: Link) -> Response:
124124
def _download(
125125
link: Link, location: str, session: PipSession, progress_bar: str
126126
) -> Tuple[str, str]:
127+
"""
128+
Common download logic across Downloader and BatchDownloader classes
129+
130+
:param link: The Link object to be downloaded
131+
:param location: path to download to
132+
:param session: PipSession object
133+
:param progress_bar: creates a `rich` progress bar is set to "on"
134+
:return: the path to the downloaded file and the content-type
135+
"""
127136
try:
128137
resp = _http_get_download(session, link)
129138
except NetworkConnectionError as e:
@@ -174,6 +183,12 @@ def _sequential_download(
174183
def _download_parallel(
175184
self, links: Iterable[Link], location: str, max_workers: int
176185
) -> Iterable[Tuple[Link, Tuple[str, str]]]:
186+
187+
"""
188+
Wraps the _sequential_download method in a ThreadPoolExecutor. `rich`
189+
progress bar doesn't support naive parallelism, hence the progress bar
190+
is disabled for parallel downloads. For more info see PR #12388
191+
"""
177192
with ThreadPoolExecutor(max_workers=max_workers) as pool:
178193
_download_parallel = partial(
179194
self._sequential_download, location=location, progress_bar="off"
@@ -188,7 +203,6 @@ def __call__(
188203
links = list(links)
189204
max_workers = self._session.parallel_downloads
190205
if max_workers == 1 or len(links) == 1:
191-
# TODO: set minimum number of links to perform parallel download
192206
for link in links:
193207
yield self._sequential_download(link, location, self._progress_bar)
194208
else:

0 commit comments

Comments
 (0)