diff options
author | Erik Johnston <erik@matrix.org> | 2016-08-15 13:45:26 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-08-15 13:45:26 +0100 |
commit | 89e786bd85331b73204294e6066dc538f1c9869c (patch) | |
tree | b12137f74605ccdb53a767f2acdcbaa290aece6a /synapse/storage | |
parent | Rename table. Add docs. (diff) | |
download | synapse-89e786bd85331b73204294e6066dc538f1c9869c.tar.xz |
Doc get_next() context manager usage
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/_base.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index c55776994d..b0923a9cad 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -873,6 +873,10 @@ class SQLBaseStore(object): txn.call_after(cache_func.invalidate, keys) 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() stream_id = ctx.__enter__() txn.call_after(ctx.__exit__, None, None, None) |