summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/util/id_generators.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py
index 2e2a408988..e5dec1c948 100644
--- a/synapse/storage/util/id_generators.py
+++ b/synapse/storage/util/id_generators.py
@@ -97,9 +97,11 @@ class StreamIdGenerator(object):
 
         @contextlib.contextmanager
         def manager():
-            yield next_id
-            with self._lock:
-                self._unfinished_ids.remove(next_id)
+            try:
+                yield next_id
+            finally:
+                with self._lock:
+                    self._unfinished_ids.remove(next_id)
 
         return manager()