From af1aef9b39da0169ea01b5441cb33ccd99dfe5a1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 21 Apr 2020 16:27:39 -0700 Subject: [PATCH] models: Move flush_per_request_caches after cache definitions. This will work around https://bugs.python.org/issue34939 when we convert the type comment to a Python 3.6 style annotation. Signed-off-by: Anders Kaseorg --- zerver/models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zerver/models.py b/zerver/models.py index 3040a97f98..99a15c1c28 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -99,12 +99,6 @@ def get_display_recipient(recipient: 'Recipient') -> DisplayRecipientT: recipient.type_id ) -def flush_per_request_caches() -> None: - global per_request_display_recipient_cache - per_request_display_recipient_cache = {} - global per_request_realm_filters_cache - per_request_realm_filters_cache = {} - def get_realm_emoji_cache_key(realm: 'Realm') -> str: return 'realm_emoji:%s' % (realm.id,) @@ -720,6 +714,12 @@ def flush_realm_filter(sender: Any, **kwargs: Any) -> None: post_save.connect(flush_realm_filter, sender=RealmFilter) post_delete.connect(flush_realm_filter, sender=RealmFilter) +def flush_per_request_caches() -> None: + global per_request_display_recipient_cache + per_request_display_recipient_cache = {} + global per_request_realm_filters_cache + per_request_realm_filters_cache = {} + # The Recipient table is used to map Messages to the set of users who # received the message. It is implemented as a set of triples (id, # type_id, type). We have 3 types of recipients: Huddles (for group