Skip to content

Commit 93093f9

Browse files
bmartinnMcSinyx
andauthored
Update src/pip/_internal/req/__init__.py
Refactor Co-authored-by: Nguyễn Gia Phong <[email protected]>
1 parent 2e39f53 commit 93093f9

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/pip/_internal/req/__init__.py

+12-20
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,21 @@ def __safe_pool_map(
103103

104104
# first let's try to install in parallel,
105105
# if we fail we do it by order.
106-
pool = None
107-
results = None
108106
try:
109107
pool = Pool()
110-
pool_result = pool.map_async(func, iterable)
111-
# python 2.7 timeout=None will not catch KeyboardInterrupt
112-
results = pool_result.get(timeout=999999)
113-
except (KeyboardInterrupt, SystemExit):
114-
if pool:
115-
pool.terminate()
116-
raise
117-
except BaseException:
118-
# This should only happen if the pool failed to initialize
119-
# we fail silently and try serial installation
120-
if pool:
108+
except ImportError:
109+
return [func(i) for i in iterable]
110+
else:
111+
try:
112+
# python 2.7 timeout=None will not catch KeyboardInterrupt
113+
results = pool.map_async(func, iterable).get(timeout=999999)
114+
except (KeyboardInterrupt, SystemExit):
121115
pool.terminate()
122-
pool = None
123-
# close pool if it was active
124-
if pool:
125-
pool.close()
126-
pool.join()
127-
128-
return results
116+
raise
117+
else:
118+
pool.close()
119+
pool.join()
120+
return results
129121

130122

131123
def __single_install(

0 commit comments

Comments
 (0)