show the stdout of player.py for debugging

This commit is contained in:
Dong Yan 2017-12-27 01:04:09 +08:00
parent 7f0565a5f6
commit c788b253fb
2 changed files with 20 additions and 9 deletions

View File

@ -54,11 +54,6 @@ if __name__ == '__main__':
# print "kill the old pyro4 name server, the return code is : " + str(kill_old_server.wait())
# time.sleep(1)
# start a name server to find the remote object
# start_new_server = subprocess.Popen(['pyro4-ns', '&'])
# print "Start Name Sever : " + str(start_new_server.pid) # + str(start_new_server.wait())
# time.sleep(1)
# start a name server if no name server exists
if len(os.popen('ps aux | grep pyro4-ns | grep -v grep').readlines()) == 0:
start_new_server = subprocess.Popen(['pyro4-ns', '&'])
@ -91,11 +86,23 @@ if __name__ == '__main__':
['python', '-u', 'player.py', '--game=' + args.game, '--role=' + black_role_name,
'--checkpoint_path=' + str(args.black_weight_path), '--debug=' + str(args.debug)],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
bp_output = black_player.stdout.readline()
bp_message = bp_output
while bp_output != '' and "Start requestLoop" not in bp_output:
bp_output = black_player.stdout.readline()
bp_message += bp_output
print("============ " + black_role_name + " message ============" + "\n" + bp_message),
white_player = subprocess.Popen(
['python', '-u', 'player.py', '--game=' + args.game, '--role=' + white_role_name,
'--checkpoint_path=' + str(args.white_weight_path), '--debug=' + str(args.debug)],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
wp_output = white_player.stdout.readline()
wp_message = wp_output
while wp_output != '' and "Start requestLoop" not in wp_output:
wp_output = white_player.stdout.readline()
wp_message += wp_output
print("============ " + white_role_name + " message ============" + "\n" + wp_message),
server_list = ""
while (black_role_name not in server_list) or (white_role_name not in server_list):

View File

@ -24,16 +24,20 @@ if __name__ == '__main__':
parser.add_argument("--game", type=str, default=False)
args = parser.parse_args()
game = Game(name=args.game, role=args.role, checkpoint_path=eval(args.checkpoint_path), debug=eval(args.debug))
if args.checkpoint_path == 'None':
args.checkpoint_path = None
game = Game(name=args.game, role=args.role,
checkpoint_path=args.checkpoint_path,
debug=eval(args.debug))
engine = GTPEngine(game_obj=game, name='tianshou', version=0)
daemon = Pyro4.Daemon() # make a Pyro daemon
ns = Pyro4.locateNS() # find the name server
player = Player(role=args.role, engine=engine)
print "Init " + args.role + " player finished"
print("Init " + args.role + " player finished")
uri = daemon.register(player) # register the greeting maker as a Pyro object
print "Start on name " + args.role
print("Start on name " + args.role)
ns.register(args.role, uri) # register the object with a name in the name server
print "Start Request Loop " + str(uri)
print("Start requestLoop " + str(uri))
daemon.requestLoop() # start the event loop of the server to wait for calls