瀏覽代碼

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):