[Python-checkins] r85318 - in python/branches/release27-maint: Lib/test/test_os.py Lib/test/win_console_handler.py Misc/NEWS
hirokazu.yamamoto
python-checkins at python.org
Fri Oct 8 11:41:14 CEST 2010
Author: hirokazu.yamamoto
Date: Fri Oct 8 11:41:13 2010
New Revision: 85318
Log:
Merged revisions 85315 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85315 | hirokazu.yamamoto | 2010-10-08 17:38:15 +0900 | 1 line
Issue #9978: Wait until subprocess completes initialization. (Win32KillTests in test_os)
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Lib/test/test_os.py
python/branches/release27-maint/Lib/test/win_console_handler.py
python/branches/release27-maint/Misc/NEWS
Modified: python/branches/release27-maint/Lib/test/test_os.py
==============================================================================
--- python/branches/release27-maint/Lib/test/test_os.py (original)
+++ python/branches/release27-maint/Lib/test/test_os.py Fri Oct 8 11:41:13 2010
@@ -11,6 +11,8 @@
import subprocess
import time
from test import test_support
+import mmap
+import uuid
warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
@@ -736,13 +738,23 @@
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.
Modified: python/branches/release27-maint/Lib/test/win_console_handler.py
==============================================================================
--- python/branches/release27-maint/Lib/test/win_console_handler.py (original)
+++ python/branches/release27-maint/Lib/test/win_console_handler.py Fri Oct 8 11:41:13 2010
@@ -11,6 +11,8 @@
from ctypes import wintypes, WINFUNCTYPE
import signal
import ctypes
+import mmap
+import sys
# Function prototype for the handler function. Returns BOOL, takes a DWORD.
HandlerRoutine = WINFUNCTYPE(wintypes.BOOL, wintypes.DWORD)
@@ -38,6 +40,10 @@
print("Unable to add SetConsoleCtrlHandler")
exit(-1)
+ # Awaken mail process
+ m = mmap.mmap(-1, 1, sys.argv[1])
+ m[0] = '1'
+
# Do nothing but wait for the signal
while True:
pass
Modified: python/branches/release27-maint/Misc/NEWS
==============================================================================
--- python/branches/release27-maint/Misc/NEWS (original)
+++ python/branches/release27-maint/Misc/NEWS Fri Oct 8 11:41:13 2010
@@ -403,6 +403,9 @@
Tests
-----
+- Issue #9978: Wait until subprocess completes initialization. (Win32KillTests
+ in test_os)
+
- Issue #9894: Do not hardcode ENOENT in test_subprocess.
- Issue #9323: Make test.regrtest.__file__ absolute, this was not always the
More information about the Python-checkins
mailing list