Skip to content

Commit

Permalink
[playframework#1355] test kill play
Browse files Browse the repository at this point in the history
  • Loading branch information
xael-fry committed Apr 2, 2022
1 parent 2f80845 commit 68c932a
Showing 1 changed file with 33 additions and 42 deletions.
75 changes: 33 additions & 42 deletions samples-and-tests/i-am-a-developer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 68c932a

Please sign in to comment.