本文整理汇总了Python中monitor.Monitor.update_timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.update_timestamp方法的具体用法?Python Monitor.update_timestamp怎么用?Python Monitor.update_timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.update_timestamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import update_timestamp [as 别名]
def main(vm_limit, config_path, skip_setup, local):
azure_config = None
if config_path:
azure_config = AzureConfig(config_path)
provisioner = Provisioner(vm_limit+1, azure_config, skip_setup, local) #+manager
monitor = None
statistics = Statistics()
# Socket setup
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('localhost', PORT))
server_socket.listen(1)
server_socket.settimeout(TIMEOUT)
# Wait for connections until receive a stop message
done = False
no_budget = False
while(True):
if done and ((monitor != None and monitor.logwatcher.watching_none()) \
or (monitor == None and provisioner.logwatcher.watching_none())) \
or no_budget:
break
try:
client_socket, _addr = server_socket.accept()
msg = receive(client_socket)
msgs = msg.split(' ')
# Stop server
if '--stop' in msgs[0]:
done = True
elif len(msgs) == 1:
if monitor != None:
raise Exception("Only one workflow can be monitored at a time")
# Parse workflow to monitor
monitor = Monitor()
wf_dir = msgs[0]
monitor.add_workflow(wf_dir)
else:
if monitor != None:
raise Exception("Only one workflow can be monitored at a time")
provisioner.update_budget_timestamp()
# Parse and schedule a new Workflow instance
wf_dir = msgs[0]
pred = msgs[1]
budget = msgs[2]
provisioner.add_workflow(wf_dir, prediction_file=pred, budget=budget)
try:
provisioner.update_schedule()
except BudgetException:
no_budget = True
client_socket.close()
except timeout:
if monitor == None and provisioner.workflow.jobs:
provisioner.update_budget_timestamp()
# Update and sync vms
provisioner.allocate_new_vms()
provisioner.deallocate_vms()
provisioner.sync_machines()
# Update, sync jobs, may reschedule
try:
provisioner.update_jobs()
except BudgetException:
no_budget = True
# Statistics
provisioner.update_wf_pred()
statistics.schedshot(provisioner)
statistics.snapshot(provisioner.timestamp, provisioner.schedule.entries, provisioner.machines)
elif monitor and monitor.workflow.jobs:
monitor.update_timestamp()
monitor.sync_machines()
monitor.sync_jobs()
statistics.snapshot(monitor.timestamp, monitor.entries, monitor.machines)
sys.stdout.flush()
if monitor == None:
entries = provisioner.schedule.entries
else:
entries = monitor.entries
statistics.jobs(entries)
statistics.dump()
if provisioner.exp:
try:
provisioner.exp.deprovision()
except Exception:
pass
#.........这里部分代码省略.........