summary refs log tree commit diff
path: root/synapse/storage/databases/main/censor_events.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-10-19 18:24:11 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-10-19 18:24:11 +0100
commit33d971bd03322d99fcfb7f38b0cbb56b521b10c2 (patch)
tree456481687929d36fb91e38c18aec902104ee84a2 /synapse/storage/databases/main/censor_events.py
parentMerge commit 'a3a59bab7' into anoa/dinsic_release_1_21_x (diff)
parentConvert account data, device inbox, and censor events databases to async/awai... (diff)
downloadsynapse-33d971bd03322d99fcfb7f38b0cbb56b521b10c2.tar.xz
Merge commit 'd68e10f30' into anoa/dinsic_release_1_21_x
* commit 'd68e10f30':
  Convert account data, device inbox, and censor events databases to async/await (#8063)
Diffstat (limited to 'synapse/storage/databases/main/censor_events.py')
-rw-r--r--synapse/storage/databases/main/censor_events.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/synapse/storage/databases/main/censor_events.py b/synapse/storage/databases/main/censor_events.py

index 1de8249563..f211ddbaf8 100644 --- a/synapse/storage/databases/main/censor_events.py +++ b/synapse/storage/databases/main/censor_events.py
@@ -16,8 +16,6 @@ import logging from typing import TYPE_CHECKING -from twisted.internet import defer - from synapse.events.utils import prune_event_dict from synapse.metrics.background_process_metrics import run_as_background_process from synapse.storage._base import SQLBaseStore @@ -148,17 +146,16 @@ class CensorEventsStore(EventsWorkerStore, CacheInvalidationWorkerStore, SQLBase updatevalues={"json": pruned_json}, ) - @defer.inlineCallbacks - def expire_event(self, event_id): + async def expire_event(self, event_id: str) -> None: """Retrieve and expire an event that has expired, and delete its associated expiry timestamp. If the event can't be retrieved, delete its associated timestamp so we don't try to expire it again in the future. Args: - event_id (str): The ID of the event to delete. + event_id: The ID of the event to delete. """ # Try to retrieve the event's content from the database or the event cache. - event = yield self.get_event(event_id) + event = await self.get_event(event_id) def delete_expired_event_txn(txn): # Delete the expiry timestamp associated with this event from the database. @@ -193,7 +190,7 @@ class CensorEventsStore(EventsWorkerStore, CacheInvalidationWorkerStore, SQLBase txn, "_get_event_cache", (event.event_id,) ) - yield self.db_pool.runInteraction( + await self.db_pool.runInteraction( "delete_expired_event", delete_expired_event_txn )