0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 18:43:53 +01:00

Use try..finally in contextlib.contextmanager

This commit is contained in:
Erik Johnston 2015-04-15 10:25:43 +01:00
parent ded4128965
commit a971fa9d58

View file

@ -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()