diff options
author | Erik Johnston <erik@matrix.org> | 2015-05-12 13:10:42 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-05-12 13:10:42 +0100 |
commit | da6a7bbdde73c5182a08a8f6253dc77761d9fc5f (patch) | |
tree | de515e4104613e4abbe0f523904f055078fc48af /synapse/storage/util | |
parent | Fix up leak. Add warnings. (diff) | |
parent | Merge pull request #148 from matrix-org/bugs/SYN-377 (diff) | |
download | synapse-da6a7bbdde73c5182a08a8f6253dc77761d9fc5f.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/logging_context
Diffstat (limited to 'synapse/storage/util')
-rw-r--r-- | synapse/storage/util/id_generators.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/synapse/storage/util/id_generators.py b/synapse/storage/util/id_generators.py index e40eb8a8c4..89d1643f10 100644 --- a/synapse/storage/util/id_generators.py +++ b/synapse/storage/util/id_generators.py @@ -78,14 +78,18 @@ class StreamIdGenerator(object): self._current_max = None self._unfinished_ids = deque() - def get_next_txn(self, txn): + @defer.inlineCallbacks + def get_next(self, store): """ Usage: - with stream_id_gen.get_next_txn(txn) as stream_id: + with yield stream_id_gen.get_next as stream_id: # ... persist event ... """ if not self._current_max: - self._get_or_compute_current_max(txn) + yield store.runInteraction( + "_compute_current_max", + self._get_or_compute_current_max, + ) with self._lock: self._current_max += 1 @@ -101,7 +105,7 @@ class StreamIdGenerator(object): with self._lock: self._unfinished_ids.remove(next_id) - return manager() + defer.returnValue(manager()) @defer.inlineCallbacks def get_max_token(self, store): |