From a1bb1c8eb19cd8604ad98c355592f010c37a55a8 Mon Sep 17 00:00:00 2001 From: acer-king Date: Sat, 12 Oct 2024 11:23:26 -0700 Subject: [PATCH] fix empty miner to assign issue --- validators/task_manager.py | 2 ++ validators/weight_setter.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/validators/task_manager.py b/validators/task_manager.py index 42233a99..7a8014f9 100644 --- a/validators/task_manager.py +++ b/validators/task_manager.py @@ -69,6 +69,8 @@ def choose_miner(self, synapse: ALL_SYNAPSE_TYPE): if bandwidth is not None and bandwidth > 0: # decrease resource by one after choosing this miner for the request. available_uids.append(uid) + if not available_uids: + return None uid = random.choice(available_uids) self.remain_resources[uid][provider][model] -= 1 return uid diff --git a/validators/weight_setter.py b/validators/weight_setter.py index 56e382a8..5f013a8c 100644 --- a/validators/weight_setter.py +++ b/validators/weight_setter.py @@ -234,6 +234,8 @@ async def perform_synthetic_queries(self): query_synapses = await self.create_query_syns_for_remaining_bandwidth() for query_syn in query_synapses: uid = self.task_mgr.assign_task(query_syn) + if uid is None: + bt.logging.debug(f"No available uids for synthetic query process.") synthetic_tasks.append((uid, self.query_miner(uid, query_syn))) bt.logging.debug(f"{time.time() - start_time} elapsed for creating and submitting synthetic queries.") @@ -448,7 +450,7 @@ async def _prompt(query_synapse: StreamPrompting, send: Send): synapse.streaming = True uid = self.task_mgr.assign_task(query_synapse) if uid is None: - bt.logging.error("Can't create task.") + bt.logging.error("Can't create task. no available uids for now") await send({"type": "http.response.body", "body": b'', "more_body": False}) return bt.logging.trace(f"task is created and uid is {uid}")