本文整理汇总了Python中agent.Agent.close方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.close方法的具体用法?Python Agent.close怎么用?Python Agent.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agent.Agent
的用法示例。
在下文中一共展示了Agent.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_power_status
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import close [as 别名]
def update_power_status(name):
# set power status of node according to status of qemu.
# 0xff: power is on.
# 0x00: power if off.
title = "chassis/nodes_power"
agent = Agent()
agent.open(name)
status = agent.get(title)
if status:
# query status of qemu process.
ps = subprocess.Popen("ps -f -C qemu-system-x86_64 | grep '{}_node_.*-node' -o".format(name),
shell=True, stdout=subprocess.PIPE)
output = ps.stdout.read()
ps.stdout.close()
ps.wait()
re_obj = re.compile("{}_node_(\d+)-node".format(name))
result = re_obj.findall(output)
result = map(lambda x: int(x), result)
# update power status.
status = ['\0'] * len(status)
for idx in result:
if idx < len(status):
status[idx] = '\xff'
agent.set(title, ''.join(status))
agent.close()
示例2: main
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import close [as 别名]
def main(game_name, lr, num_agents, update_target_every, model_name, tau):
assert 'NoFrameskip-v4' in game_name
if 'soft' in model_name:
update_target_every = 1
basename = '{}:lr={}:na={}:ute={}:{}'.format(
game_name[:-14], lr, num_agents, update_target_every, model_name)
if 'soft' in model_name:
basename += ':tau={}'.format(tau)
env = Agent(num_agents, game_name, basename)
try:
estimator = get_estimator(model_name, env.action_n, lr, 0.99, tau=tau)
base_path = os.path.join(train_path, basename)
print("start training!!")
dqn(env,
estimator,
base_path,
batch_size=32,
epsilon=0.01,
save_model_every=1000,
update_target_every=update_target_every,
learning_starts=200,
memory_size=100000,
num_iterations=40000000)
except KeyboardInterrupt:
print("\nKeyboard interrupt!!")
except Exception:
traceback.print_exc()
finally:
env.close()
示例3: test_socket_bind_error
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import close [as 别名]
def test_socket_bind_error():
# Block socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((Supernova.payload_ip(Supernova.get_my_id()),
Supernova.service_recv_port("Payload Command", Supernova.get_my_id())) )
a = Agent()
a.bind_udp_sockets() # will fail gracefully
a.close()
sock.close()