File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import shutil
1414from test import support
1515import contextlib
16+ import mmap
17+ import uuid
1618
1719# Detect whether we're on a Linux system that uses the (now outdated
1820# and unmaintained) linuxthreads threading library. There's an issue
@@ -1029,13 +1031,23 @@ def test_kill_int(self):
10291031 self ._kill (100 )
10301032
10311033 def _kill_with_event (self , event , name ):
1034+ tagname = "test_os_%s" % uuid .uuid1 ()
1035+ m = mmap .mmap (- 1 , 1 , tagname )
1036+ m [0 ] = 0
10321037 # Run a script which has console control handling enabled.
10331038 proc = subprocess .Popen ([sys .executable ,
10341039 os .path .join (os .path .dirname (__file__ ),
1035- "win_console_handler.py" )],
1040+ "win_console_handler.py" ), tagname ],
10361041 creationflags = subprocess .CREATE_NEW_PROCESS_GROUP )
10371042 # Let the interpreter startup before we send signals. See #3137.
1038- time .sleep (0.5 )
1043+ count , max = 0 , 20
1044+ while count < max and proc .poll () is None :
1045+ if m [0 ] == 0 :
1046+ break
1047+ time .sleep (0.5 )
1048+ count += 1
1049+ else :
1050+ self .fail ("Subprocess didn't finish initialization" )
10391051 os .kill (proc .pid , event )
10401052 # proc.send_signal(event) could also be done here.
10411053 # Allow time for the signal to be passed and the process to exit.
Original file line number Diff line number Diff line change 1111from ctypes import wintypes , WINFUNCTYPE
1212import signal
1313import ctypes
14+ import mmap
15+ import sys
1416
1517# Function prototype for the handler function. Returns BOOL, takes a DWORD.
1618HandlerRoutine = WINFUNCTYPE (wintypes .BOOL , wintypes .DWORD )
@@ -38,6 +40,10 @@ def _ctrl_handler(sig):
3840 print ("Unable to add SetConsoleCtrlHandler" )
3941 exit (- 1 )
4042
43+ # Awaken mail process
44+ m = mmap .mmap (- 1 , 1 , sys .argv [1 ])
45+ m [0 ] = 1
46+
4147 # Do nothing but wait for the signal
4248 while True :
4349 pass
Original file line number Diff line number Diff line change @@ -311,6 +311,9 @@ Tools/Demos
311311Tests
312312-----
313313
314+ - Issue #9978: Wait until subprocess completes initialization. (Win32KillTests
315+ in test_os)
316+
314317- Issue #7110: regrtest now sends test failure reports and single-failure
315318 tracebacks to stderr rather than stdout.
316319
You can’t perform that action at this time.
0 commit comments