Use try..finally in contextlib.contextmanager
This commit is contained in:
parent
ded4128965
commit
a971fa9d58
|
@ -97,7 +97,9 @@ class StreamIdGenerator(object):
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def manager():
|
def manager():
|
||||||
|
try:
|
||||||
yield next_id
|
yield next_id
|
||||||
|
finally:
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self._unfinished_ids.remove(next_id)
|
self._unfinished_ids.remove(next_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue