Skip to content

Commit 7fdbc84

Browse files
committed
issue bigscience-workshop#389 mitigation
1 parent f6be1f7 commit 7fdbc84

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/petals/server/server.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,24 @@ def _should_choose_other_blocks(self) -> bool:
414414
return False
415415

416416
module_infos = get_remote_module_infos(self.dht, self.module_uids, latest=True)
417-
return block_selection.should_choose_other_blocks(self.dht.peer_id, module_infos, self.balance_quality)
417+
should_choose = block_selection.should_choose_other_blocks(self.dht.peer_id, module_infos, self.balance_quality)
418+
419+
if False == should_choose:
420+
return False
421+
else:
422+
for i in range(2):
423+
wait_time = 90 + random.randint(-30, 10)
424+
time.sleep(wait_time)
425+
426+
module_infos = get_remote_module_infos(self.dht, self.module_uids, latest=True)
427+
logger.info('--retrying should_choose_other_blocks')
428+
should_choose = block_selection.should_choose_other_blocks(self.dht.peer_id, module_infos, self.balance_quality)
429+
430+
if False == should_choose:
431+
return False
432+
433+
return should_choose
434+
418435

419436
def shutdown(self, timeout: Optional[float] = 5):
420437
self.stop.set()

0 commit comments

Comments
 (0)