summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-15 10:25:43 +0100
committerErik Johnston <erik@matrix.org>2015-04-15 10:25:43 +0100
commita971fa9d584b35c35b675b65ed86faed77b46cf7 (patch)
tree1502086c946cae0985c12d26fbb55759f6e60bfc /synapse/storage
parentUse True for True rather than 1 (diff)
downloadsynapse-a971fa9d584b35c35b675b65ed86faed77b46cf7.tar.xz
Use try..finally in contextlib.contextmanager
Diffstat (limited to 'synapse/storage')
-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()