1
0
mirror of https://github.com/newnius/YAO-agent.git synced 2025-06-07 13:51:56 +00:00

launch in background

This commit is contained in:
Newnius 2020-04-11 10:51:51 +08:00
parent bcfeb73ad2
commit 7412b142f1

View File

@ -28,18 +28,7 @@ ver = 0
last_version = {} last_version = {}
def launch_tasks(stats): def launch_task_in_background(container, task_id):
utils = {}
for stat in stats:
utils[stat['uuid']] = stat['utilization_gpu']
client = docker.from_env()
container = client.containers.get('yao-agent-helper')
entries_to_remove = []
lock.acquire()
for task_id, task in pending_tasks.items():
if int(utils[task['gpus'][0]]) < 60:
entries_to_remove.append(task_id)
script = " ".join([ script = " ".join([
"docker exec", "docker exec",
task_id, task_id,
@ -53,6 +42,23 @@ def launch_tasks(stats):
break break
time.sleep(0.1) time.sleep(0.1)
def launch_tasks(stats):
utils = {}
for stat in stats:
utils[stat['uuid']] = stat['utilization_gpu']
client = docker.from_env()
container = client.containers.get('yao-agent-helper')
entries_to_remove = []
lock.acquire()
for task_id, task in pending_tasks.items():
if int(utils[task['gpus'][0]]) < 60:
entries_to_remove.append(task_id)
t = Thread(target=launch_task_in_background, name='launch_task', args=(container, task_id,))
t.start()
for k in entries_to_remove: for k in entries_to_remove:
pending_tasks.pop(k, None) pending_tasks.pop(k, None)
lock.release() lock.release()