소스 검색

try-finally

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

+ 5 - 3
hivemind/averaging/matchmaking.py

@@ -88,9 +88,11 @@ class Matchmaking:
     async def looking_for_group(self, step_control: StepControl):
         async with self.lock_looking_for_group:
             assert self.step_control is None
-            self.step_control = step_control
-            yield
-            self.step_control = None
+            try:
+                self.step_control = step_control
+                yield
+            finally:
+                self.step_control = None
 
     @property
     def is_looking_for_group(self):