Anonymous avatar Anonymous committed 1b24254

Slightly modified patch from http://scons.tigris.org/issues/show_bug.cgi?id=2449, implementing thread safe os.spawnve on windows.

Comments (0)

Files changed (1)

src/engine/SCons/Platform/win32.py

 import os.path
 import sys
 import tempfile
+import threading
 
 from SCons.Platform.posix import exitvalmap
 from SCons.Platform import TempFileMunge
     builtins.file = _scons_file
     builtins.open = _scons_open
 
+spawn_lock = threading.Lock()
 
+def spawnve(mode, file, args, env):
+    spawn_lock.acquire()
+    try:
+        if mode == os.P_WAIT:
+            ret = os.spawnve(os.P_NOWAIT, file, args, env)
+        else:
+            ret = os.spawnve(mode, file, args, env)
+    finally:
+        spawn_lock.release()
+    if mode == os.P_WAIT:
+        pid, status = os.waitpid(ret, 0)
+        ret = status >> 8
+    return ret
 
 # The upshot of all this is that, if you are using Python 1.5.2,
 # you had better have cmd or command.com in your PATH when you run
         # actually do the spawn
         try:
             args = [sh, '/C', escape(' '.join(args)) ]
-            ret = os.spawnve(os.P_WAIT, sh, args, env)
+            ret = spawnve(os.P_WAIT, sh, args, env)
         except OSError, e:
             # catch any error
             try:
 
 def exec_spawn(l, env):
     try:
-        result = os.spawnve(os.P_WAIT, l[0], l, env)
+        result = spawnve(os.P_WAIT, l[0], l, env)
     except OSError, e:
         try:
             result = exitvalmap[e[0]]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.