summaryrefslogtreecommitdiff
path: root/scons
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-07-14 11:09:23 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-07-14 12:21:25 +0100
commit7325c1ebc8cf88249d0adeadc0f52600e727c762 (patch)
treed0d88a93ff2cd9ec2fbfeeb8ede95753fdb98b23 /scons
parent4ed1de8b84b587d2be0c0e4ecb6b5f421195f562 (diff)
scons: Monkey patch os.spawnve on Windows to become thread safe.
See also: - http://bugs.python.org/issue6476 - http://scons.tigris.org/issues/show_bug.cgi?id=2449
Diffstat (limited to 'scons')
-rw-r--r--scons/fixes.py27
-rw-r--r--scons/gallium.py2
2 files changed, 29 insertions, 0 deletions
diff --git a/scons/fixes.py b/scons/fixes.py
new file mode 100644
index 0000000000..714cccf61d
--- /dev/null
+++ b/scons/fixes.py
@@ -0,0 +1,27 @@
+import sys
+
+# Monkey patch os.spawnve on windows to become thread safe
+if sys.platform == 'win32':
+ import os
+ import threading
+ from os import spawnve as old_spawnve
+
+ spawn_lock = threading.Lock()
+
+ def new_spawnve(mode, file, args, env):
+ spawn_lock.acquire()
+ try:
+ if mode == os.P_WAIT:
+ ret = old_spawnve(os.P_NOWAIT, file, args, env)
+ else:
+ ret = old_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
+
+ os.spawnve = new_spawnve
+
+
diff --git a/scons/gallium.py b/scons/gallium.py
index 217478bd50..8082aba6f2 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -38,6 +38,8 @@ import SCons.Action
import SCons.Builder
import SCons.Scanner
+import fixes
+
def quietCommandLines(env):
# Quiet command lines