Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc2b4cf

Browse files
committed
If multiprocessing fails, don't use it during setup.
1 parent 9877224 commit bc2b4cf

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

setup.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,27 @@ def run_2to3(self, files):
299299
filtered = [x for x in files if should_2to3(x, self.build_lib)]
300300
if sys.platform.startswith('win') or 'TRAVIS' in os.environ:
301301
# doing this in parallel on windows may crash your computer
302-
[refactor(f) for f in filtered]
302+
self.run_2to3_uniprocess(filtered)
303303
else:
304+
self.run_2to3_multiprocess(filtered)
305+
print()
306+
307+
def run_2to3_uniprocess(self, files):
308+
for i, f in enumerate(files):
309+
print("Running 2to3... %.02f%%" %
310+
(float(i) / len(files) * 100.0), end='\r')
311+
refactor(f)
312+
313+
def run_2to3_multiprocess(self, files):
314+
try:
304315
p = multiprocessing.Pool()
305-
for i, x in enumerate(p.imap_unordered(refactor, filtered)):
316+
except:
317+
self.run_2to3_uniprocess(files)
318+
else:
319+
for i, x in enumerate(p.imap_unordered(refactor, files)):
306320
print("Running 2to3... %.02f%%" %
307-
(float(i) / len(filtered) * 100.0), end='\r')
308-
print()
321+
(float(i) / len(files) * 100.0), end='\r')
322+
309323

310324
print_raw("pymods %s" % py_modules)
311325
print_raw("packages %s" % packages)

0 commit comments

Comments
 (0)