diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-07-19 11:04:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-19 11:04:18 +0100 |
commit | c754e006f4860718057ad6dded91e66f6239bb57 (patch) | |
tree | 6101a439c55c0f6d41c8d13cf5ff985e21fd9d51 /synapse/storage/client_ips.py | |
parent | Move v1-only APIs into their own module & isolate deprecated ones (#3460) (diff) | |
parent | Make Distributor run its processes as a background process (diff) | |
download | synapse-c754e006f4860718057ad6dded91e66f6239bb57.tar.xz |
Merge pull request #3556 from matrix-org/rav/background_processes
Run things as background processes
Diffstat (limited to 'synapse/storage/client_ips.py')
-rw-r--r-- | synapse/storage/client_ips.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/synapse/storage/client_ips.py b/synapse/storage/client_ips.py index b78eda3413..77ae10da3d 100644 --- a/synapse/storage/client_ips.py +++ b/synapse/storage/client_ips.py @@ -19,6 +19,7 @@ from six import iteritems from twisted.internet import defer +from synapse.metrics.background_process_metrics import run_as_background_process from synapse.util.caches import CACHE_SIZE_FACTOR from . import background_updates @@ -93,10 +94,16 @@ class ClientIpStore(background_updates.BackgroundUpdateStore): self._batch_row_update[key] = (user_agent, device_id, now) def _update_client_ips_batch(self): - to_update = self._batch_row_update - self._batch_row_update = {} - return self.runInteraction( - "_update_client_ips_batch", self._update_client_ips_batch_txn, to_update + def update(): + to_update = self._batch_row_update + self._batch_row_update = {} + return self.runInteraction( + "_update_client_ips_batch", self._update_client_ips_batch_txn, + to_update, + ) + + run_as_background_process( + "update_client_ips", update, ) def _update_client_ips_batch_txn(self, txn, to_update): |