소스 검색

cancelled clause

justheuristic 3 년 전
부모
커밋
66655f7376
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      hivemind/averaging/matchmaking.py

+ 3 - 0
hivemind/averaging/matchmaking.py

@@ -152,6 +152,9 @@ class Matchmaking:
         async with self.potential_leaders.begin_search(step, self.group_key_manager, declare=not self.client_mode):
             while True:
                 try:
+                    if step.cancelled():
+                        raise asyncio.CancelledError("Finishing abruptly because matchmaking was cancelled")
+
                     next_leader = await self.potential_leaders.pop_next_leader()  # throws TimeoutError on expiration
 
                     group = await self._request_join_group(next_leader)