mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-27 20:52:30 +00:00
Use try..finally in contextlib.contextmanager
This commit is contained in:
parent
ded4128965
commit
a971fa9d58
@ -97,9 +97,11 @@ class StreamIdGenerator(object):
|
|||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def manager():
|
def manager():
|
||||||
yield next_id
|
try:
|
||||||
with self._lock:
|
yield next_id
|
||||||
self._unfinished_ids.remove(next_id)
|
finally:
|
||||||
|
with self._lock:
|
||||||
|
self._unfinished_ids.remove(next_id)
|
||||||
|
|
||||||
return manager()
|
return manager()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user