mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Doc get_next() context manager usage
This commit is contained in:
parent
d9664344ec
commit
89e786bd85
@ -873,6 +873,10 @@ class SQLBaseStore(object):
|
|||||||
txn.call_after(cache_func.invalidate, keys)
|
txn.call_after(cache_func.invalidate, keys)
|
||||||
|
|
||||||
if isinstance(self.database_engine, PostgresEngine):
|
if isinstance(self.database_engine, PostgresEngine):
|
||||||
|
# get_next() returns a context manager which is designed to wrap
|
||||||
|
# the transaction. However, we want to only get an ID when we want
|
||||||
|
# to use it, here, so we need to call __enter__ manually, and have
|
||||||
|
# __exit__ called after the transaction finishes.
|
||||||
ctx = self._cache_id_gen.get_next()
|
ctx = self._cache_id_gen.get_next()
|
||||||
stream_id = ctx.__enter__()
|
stream_id = ctx.__enter__()
|
||||||
txn.call_after(ctx.__exit__, None, None, None)
|
txn.call_after(ctx.__exit__, None, None, None)
|
||||||
|
Loading…
Reference in New Issue
Block a user