diff --git a/zerver/lib/db.py b/zerver/lib/db.py index df547dba3d..9d3fedead5 100644 --- a/zerver/lib/db.py +++ b/zerver/lib/db.py @@ -51,11 +51,3 @@ class TimeTrackingConnection(connection): def __init__(self, *args: Any, **kwargs: Any) -> None: self.queries: List[Dict[str, str]] = [] super().__init__(*args, **kwargs) - - -def reset_queries() -> None: - from django.db import connections - - for conn in connections.all(): - if conn.connection is not None: - conn.connection.queries = [] diff --git a/zerver/lib/db_connections.py b/zerver/lib/db_connections.py new file mode 100644 index 0000000000..af60299ce6 --- /dev/null +++ b/zerver/lib/db_connections.py @@ -0,0 +1,7 @@ +from django.db import connections + + +def reset_queries() -> None: + for conn in connections.all(): + if conn.connection is not None: + conn.connection.queries = [] diff --git a/zerver/middleware.py b/zerver/middleware.py index 1ecee11652..ec75a91fdb 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -25,7 +25,7 @@ from sentry_sdk import set_tag from typing_extensions import Annotated, Concatenate, ParamSpec, override from zerver.lib.cache import get_remote_cache_requests, get_remote_cache_time -from zerver.lib.db import reset_queries +from zerver.lib.db_connections import reset_queries from zerver.lib.debug import maybe_tracemalloc_listen from zerver.lib.exceptions import ErrorCode, JsonableError, MissingAuthenticationError, WebhookError from zerver.lib.markdown import get_markdown_requests, get_markdown_time diff --git a/zerver/worker/base.py b/zerver/worker/base.py index 8b99f0a695..8430b974a9 100644 --- a/zerver/worker/base.py +++ b/zerver/worker/base.py @@ -16,7 +16,7 @@ from returns.curry import partial from typing_extensions import override from zerver.lib.context_managers import lockfile -from zerver.lib.db import reset_queries +from zerver.lib.db_connections import reset_queries from zerver.lib.per_request_cache import flush_per_request_caches from zerver.lib.pysa import mark_sanitized from zerver.lib.queue import SimpleQueueClient diff --git a/zerver/worker/missedmessage_emails.py b/zerver/worker/missedmessage_emails.py index 9ad011d6a7..ccf734d5b4 100644 --- a/zerver/worker/missedmessage_emails.py +++ b/zerver/worker/missedmessage_emails.py @@ -11,7 +11,7 @@ from django.db.utils import IntegrityError from django.utils.timezone import now as timezone_now from typing_extensions import override -from zerver.lib.db import reset_queries +from zerver.lib.db_connections import reset_queries from zerver.lib.email_notifications import MissedMessageData, handle_missedmessage_emails from zerver.lib.per_request_cache import flush_per_request_caches from zerver.models import ScheduledMessageNotificationEmail