|
46 | 46 | import traceback |
47 | 47 | import sysconfig |
48 | 48 | import platform |
| 49 | +import threading |
49 | 50 |
|
50 | 51 | import SCons.CacheDir |
51 | 52 | import SCons.Debug |
|
80 | 81 | delayed_warnings = [] |
81 | 82 |
|
82 | 83 |
|
83 | | -def fetch_win32_parallel_msg(): |
84 | | - # A subsidiary function that exists solely to isolate this import |
85 | | - # so we don't have to pull it in on all platforms, and so that an |
86 | | - # in-line "import" statement in the _main() function below doesn't |
87 | | - # cause warnings about local names shadowing use of the 'SCons' |
88 | | - # global in nest scopes and UnboundLocalErrors and the like in some |
89 | | - # versions (2.1) of Python. |
90 | | - import SCons.Platform.win32 |
91 | | - return SCons.Platform.win32.parallel_msg |
92 | | - |
93 | | - |
94 | 84 | def revert_io(): |
95 | 85 | # This call is added to revert stderr and stdout to the original |
96 | 86 | # ones just in case some build rule or something else in the system |
@@ -1281,16 +1271,19 @@ def tmtrace_cleanup(tfile): |
1281 | 1271 | # As of 3.7, python removed support for threadless platforms. |
1282 | 1272 | # See https://www.python.org/dev/peps/pep-0011/ |
1283 | 1273 | is_37_or_later = sys.version_info >= (3, 7) |
1284 | | - python_has_threads = sysconfig.get_config_var('WITH_THREAD') or is_pypy or is_37_or_later |
| 1274 | + # python_has_threads = sysconfig.get_config_var('WITH_THREAD') or is_pypy or is_37_or_later |
| 1275 | + |
| 1276 | + # As of python 3.4 threading has a dummy_threading module for use when there is no threading |
| 1277 | + # it's get_ident() will allways return -1, while real threading modules get_ident() will |
| 1278 | + # always return a positive integer |
| 1279 | + python_has_threads = threading.get_ident() != -1 |
1285 | 1280 | # to check if python configured with threads. |
1286 | 1281 | global num_jobs |
1287 | 1282 | num_jobs = options.num_jobs |
1288 | 1283 | jobs = SCons.Job.Jobs(num_jobs, taskmaster) |
1289 | 1284 | if num_jobs > 1: |
1290 | 1285 | msg = None |
1291 | | - if sys.platform == 'win32': |
1292 | | - msg = fetch_win32_parallel_msg() |
1293 | | - elif jobs.num_jobs == 1 or not python_has_threads: |
| 1286 | + if jobs.num_jobs == 1 or not python_has_threads: |
1294 | 1287 | msg = "parallel builds are unsupported by this version of Python;\n" + \ |
1295 | 1288 | "\tignoring -j or num_jobs option.\n" |
1296 | 1289 | if msg: |
|
0 commit comments