File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,11 +108,22 @@ def test_terminate(self):
108108
109109 @unittest .skipIf (sys .platform == 'win32' , "Don't have SIGHUP" )
110110 def test_send_signal (self ):
111- args = PROGRAM_BLOCKED
112- create = asyncio .create_subprocess_exec (* args , loop = self .loop )
111+ code = 'import time; print("sleeping", flush=True); time.sleep(3600)'
112+ args = [sys .executable , '-c' , code ]
113+ create = asyncio .create_subprocess_exec (* args , loop = self .loop , stdout = subprocess .PIPE )
113114 proc = self .loop .run_until_complete (create )
114- proc .send_signal (signal .SIGHUP )
115- returncode = self .loop .run_until_complete (proc .wait ())
115+
116+ @asyncio .coroutine
117+ def send_signal (proc ):
118+ # basic synchronization to wait until the program is sleeping
119+ line = yield from proc .stdout .readline ()
120+ self .assertEqual (line , b'sleeping\n ' )
121+
122+ proc .send_signal (signal .SIGHUP )
123+ returncode = (yield from proc .wait ())
124+ return returncode
125+
126+ returncode = self .loop .run_until_complete (send_signal (proc ))
116127 self .assertEqual (- signal .SIGHUP , returncode )
117128
118129 def prepare_broken_pipe_test (self ):
You can’t perform that action at this time.
0 commit comments