mirror of
https://github.com/newnius/YAO-agent.git
synced 2025-06-07 05:41:56 +00:00
launch in background
This commit is contained in:
parent
bcfeb73ad2
commit
7412b142f1
30
agent.py
30
agent.py
@ -28,18 +28,7 @@ ver = 0
|
||||
last_version = {}
|
||||
|
||||
|
||||
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)
|
||||
def launch_task_in_background(container, task_id):
|
||||
script = " ".join([
|
||||
"docker exec",
|
||||
task_id,
|
||||
@ -53,6 +42,23 @@ def launch_tasks(stats):
|
||||
break
|
||||
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:
|
||||
pending_tasks.pop(k, None)
|
||||
lock.release()
|
||||
|
Loading…
Reference in New Issue
Block a user