summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2010-10-08 08:38:15 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2010-10-08 08:38:15 (GMT)
commit54c950f6b4e3e8449ba62c3e54445af9d273ae68 (patch)
treec8cc56f02a08d9f3d690693d8cb8b6922d7e379f /Lib/test/test_os.py
parentbc95973b51abadc84960e7836ce313f12cf515cf (diff)
downloadcpython-54c950f6b4e3e8449ba62c3e54445af9d273ae68.zip
cpython-54c950f6b4e3e8449ba62c3e54445af9d273ae68.tar.gz
cpython-54c950f6b4e3e8449ba62c3e54445af9d273ae68.tar.bz2
Issue #9978: Wait until subprocess completes initialization. (Win32KillTests in test_os)
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index d73bff2..342dada 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -13,6 +13,8 @@ import time
import shutil
from test import support
import contextlib
+import mmap
+import uuid
# Detect whether we're on a Linux system that uses the (now outdated
# and unmaintained) linuxthreads threading library. There's an issue
@@ -1029,13 +1031,23 @@ class Win32KillTests(unittest.TestCase):
self._kill(100)
def _kill_with_event(self, event, name):
+ tagname = "test_os_%s" % uuid.uuid1()
+ m = mmap.mmap(-1, 1, tagname)
+ m[0] = 0
# Run a script which has console control handling enabled.
proc = subprocess.Popen([sys.executable,
os.path.join(os.path.dirname(__file__),
- "win_console_handler.py")],
+ "win_console_handler.py"), tagname],
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
# Let the interpreter startup before we send signals. See #3137.
- time.sleep(0.5)
+ count, max = 0, 20
+ while count < max and proc.poll() is None:
+ if m[0] == 0:
+ break
+ time.sleep(0.5)
+ count += 1
+ else:
+ self.fail("Subprocess didn't finish initialization")
os.kill(proc.pid, event)
# proc.send_signal(event) could also be done here.
# Allow time for the signal to be passed and the process to exit.