Skip to content

Commit 98d4cbf

Browse files
committed
(joe) switch from multiprocessing.pool to internal wrapper, thanks to @McSinyx and @uranusjr for the warning about the weird ways in which different pythons are broken
1 parent 58259e8 commit 98d4cbf

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/pip/_internal/resolution/resolvelib/resolver.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
)
2323
from pip._internal.utils.deprecation import deprecated
2424
from pip._internal.utils.filetypes import is_archive_file
25+
from pip._internal.utils.parallel import map_multithread, LACK_SEM_OPEN
2526

2627
from .base import Candidate, Requirement
2728
from .factory import Factory
@@ -90,15 +91,21 @@ def resolve(
9091
reporter,
9192
)
9293

93-
def _maybe_find_candidates(req: Requirement) -> None:
94-
ident = provider.identify(req)
95-
try:
96-
self.factory._finder.find_all_candidates(ident)
97-
except AttributeError:
98-
pass
9994

100-
with ThreadPool() as tp:
101-
for _ in tp.imap_unordered(_maybe_find_candidates, collected.requirements):
95+
if LACK_SEM_OPEN:
96+
# if a working threading implementation unavailable do nothing
97+
pass
98+
else:
99+
# otherwise greedily call/consume _finder.find_all_candidates in parallel in order to
100+
# populate the lru cache such that future calls don't block on networking
101+
def _maybe_find_candidates(req: Requirement) -> None:
102+
ident = provider.identify(req)
103+
try:
104+
self.factory._finder.find_all_candidates(ident)
105+
except AttributeError:
106+
pass
107+
108+
for _ in map_multithread(_maybe_find_candidates, collected.requirements):
102109
pass
103110

104111
try:

0 commit comments

Comments
 (0)