15 lines
357 B
Plaintext
15 lines
357 B
Plaintext
# -*- coding:utf-8 -*-
|
|
# GET /api/gpu_lock - GPU锁状态
|
|
|
|
import aioredis
|
|
|
|
r = await aioredis.from_url('redis://127.0.0.1:6379', decode_responses=True)
|
|
result = {}
|
|
for gpu_id in range(8):
|
|
key = f'gpu:lock:{gpu_id}'
|
|
owner = await r.get(key)
|
|
result[gpu_id] = {'busy': owner is not None, 'owner': owner}
|
|
await r.close()
|
|
|
|
return json.dumps(result)
|