Skip to content

Commit

Permalink
(joe) switch from multiprocessing.pool to internal wrapper, thanks to @…
Browse files Browse the repository at this point in the history
…McSinyx and @uranusjr for the warning about the weird ways in which different pythons are broken
  • Loading branch information
jbylund committed Sep 21, 2021
1 parent 58259e8 commit 98d4cbf
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.filetypes import is_archive_file
from pip._internal.utils.parallel import map_multithread, LACK_SEM_OPEN

from .base import Candidate, Requirement
from .factory import Factory
Expand Down Expand Up @@ -90,15 +91,21 @@ def resolve(
reporter,
)

def _maybe_find_candidates(req: Requirement) -> None:
ident = provider.identify(req)
try:
self.factory._finder.find_all_candidates(ident)
except AttributeError:
pass

with ThreadPool() as tp:
for _ in tp.imap_unordered(_maybe_find_candidates, collected.requirements):
if LACK_SEM_OPEN:
# if a working threading implementation unavailable do nothing
pass
else:
# otherwise greedily call/consume _finder.find_all_candidates in parallel in order to
# populate the lru cache such that future calls don't block on networking
def _maybe_find_candidates(req: Requirement) -> None:
ident = provider.identify(req)
try:
self.factory._finder.find_all_candidates(ident)
except AttributeError:
pass

for _ in map_multithread(_maybe_find_candidates, collected.requirements):
pass

try:
Expand Down

0 comments on commit 98d4cbf

Please sign in to comment.