diff options
author | Erik Johnston <erik@matrix.org> | 2015-04-15 10:25:43 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-04-15 10:25:43 +0100 |
commit | a971fa9d584b35c35b675b65ed86faed77b46cf7 (patch) | |
tree | 1502086c946cae0985c12d26fbb55759f6e60bfc /synapse/storage | |
parent | Use True for True rather than 1 (diff) | |
download | synapse-a971fa9d584b35c35b675b65ed86faed77b46cf7.tar.xz |
Use try..finally in contextlib.contextmanager
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/util/id_generators.py | 8 |
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() |