File tree Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -103,29 +103,23 @@ def __safe_pool_map(
103
103
104
104
# first let's try to install in parallel,
105
105
# if we fail we do it by order.
106
- pool = None
107
- results = None
108
106
try :
107
+ # Pool context would have been nice, but not supported on Python 2.7
108
+ # Once officially dropped, switch to context to avoid close/join calls
109
109
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 :
110
+ except ImportError :
111
+ return [func (i ) for i in iterable ]
112
+ else :
113
+ try :
114
+ # python 2.7 timeout=None will not catch KeyboardInterrupt
115
+ results = pool .map_async (func , iterable ).get (timeout = 999999 )
116
+ except (KeyboardInterrupt , SystemExit ):
121
117
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
118
+ raise
119
+ else :
120
+ pool .close ()
121
+ pool .join ()
122
+ return results
129
123
130
124
131
125
def __single_install (
You can’t perform that action at this time.
0 commit comments