Browse Source

try-finally

justheuristic 3 years ago
parent
commit
6b058123b0
1 changed files with 5 additions and 3 deletions
  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 def looking_for_group(self, step_control: StepControl):
         async with self.lock_looking_for_group:
         async with self.lock_looking_for_group:
             assert self.step_control is None
             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
     @property
     def is_looking_for_group(self):
     def is_looking_for_group(self):