From 68c932a811ecf7bde851b98497cdb961840b7e24 Mon Sep 17 00:00:00 2001 From: Alexandre Chatiron Date: Sat, 2 Apr 2022 18:12:00 +0200 Subject: [PATCH] [#1355] test kill play --- samples-and-tests/i-am-a-developer/tests.py | 75 +++++++++------------ 1 file changed, 33 insertions(+), 42 deletions(-) diff --git a/samples-and-tests/i-am-a-developer/tests.py b/samples-and-tests/i-am-a-developer/tests.py index b3211d76d3..e6c152e9c6 100755 --- a/samples-and-tests/i-am-a-developer/tests.py +++ b/samples-and-tests/i-am-a-developer/tests.py @@ -858,50 +858,41 @@ def timeout(process): def killPlay(process, http='http'): print("kill %s" % process.pid) try: - urllib.request.urlopen('%s://localhost:9000/@kill' % http) + print("terminate" ) + process.terminate() + + print("process 1 (thread): kill process 2 (pid %s)" % process.pid) + process.kill() + print("process 1 (thread): close process 2 stdout pipe (fd %s)" % process.stdout.fileno()) + + print("stdout" ) + if process.stdout: + process.stdout.close() + + if process.stderr: + process.stderr.close() + + if process.stdin: + process.stdin.close() + + + print("wait" ) + process.wait(10) + print("wait" ) + process.wait() + + print("KILLED") + # kill subprocess tree, because calling urllib.urlopen(f"{http}://localhost:9000/@kill") is not enough + while True: + if process.poll() is None: + print("Kill Play subprocess") + os.kill(process.pid, SIGTERM) + process.wait(3) + else: + print("KILLED") + return except: pass -# urllib.request.urlopen(f"{http}://" + 'localhost' + ':' + '9001' + '/@kill') - -# print("terminate" ) -# process.terminate() -# -# print("process 1 (thread): kill process 2 (pid %s)" % process.pid) -# process.kill() -# print("process 1 (thread): close process 2 stdout pipe (fd %s)" % process.stdout.fileno()) -# -# print("stdout" ) -# if process.stdout: -# process.stdout.close() -# -# if process.stderr: -# process.stderr.close() -# -# if process.stdin: -# process.stdin.close() -# -# -# print("wait" ) -# process.wait(10) -# print("wait" ) -# process.wait() -# # -# id = process.pid -# -# print("os.kill %s" % id ) -# -# # os.kill(id, SIGTERM) -# -# print("KILLED") -# # kill subprocess tree, because calling urllib.urlopen(f"{http}://localhost:9000/@kill") is not enough -# while True: -# if process.poll() is None: -# print("Kill Play subprocess") -# os.kill(process.pid, SIGTERM) -# process.wait(3) -# else: -# print("KILLED") -# return def step(msg):