Skip to content
Snippets Groups Projects
Unverified Commit dc6fb56c authored by Brendan Abolivier's avatar Brendan Abolivier
Browse files

Hopefully mypy is happy now

parent fe593ef9
No related branches found
No related tags found
No related merge requests found
...@@ -210,7 +210,7 @@ class LoggingContext(object): ...@@ -210,7 +210,7 @@ class LoggingContext(object):
class Sentinel(object): class Sentinel(object):
"""Sentinel to represent the root context""" """Sentinel to represent the root context"""
__slots__ = ["previous_context", "alive", "request", "scope"] __slots__ = ["previous_context", "alive", "request", "scope", "tag"]
def __init__(self) -> None: def __init__(self) -> None:
# Minimal set for compatibility with LoggingContext # Minimal set for compatibility with LoggingContext
...@@ -218,6 +218,7 @@ class LoggingContext(object): ...@@ -218,6 +218,7 @@ class LoggingContext(object):
self.alive = None self.alive = None
self.request = None self.request = None
self.scope = None self.scope = None
self.tag = None
def __str__(self): def __str__(self):
return "sentinel" return "sentinel"
......
...@@ -29,7 +29,11 @@ from twisted.internet import defer ...@@ -29,7 +29,11 @@ from twisted.internet import defer
from synapse.api.errors import StoreError from synapse.api.errors import StoreError
from synapse.config.database import DatabaseConnectionConfig from synapse.config.database import DatabaseConnectionConfig
from synapse.logging.context import LoggingContext, make_deferred_yieldable from synapse.logging.context import (
LoggingContext,
LoggingContextOrSentinel,
make_deferred_yieldable,
)
from synapse.metrics.background_process_metrics import run_as_background_process from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.storage.background_updates import BackgroundUpdater from synapse.storage.background_updates import BackgroundUpdater
from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine, Sqlite3Engine from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine, Sqlite3Engine
...@@ -543,7 +547,9 @@ class Database(object): ...@@ -543,7 +547,9 @@ class Database(object):
Returns: Returns:
Deferred: The result of func Deferred: The result of func
""" """
parent_context = LoggingContext.current_context() parent_context = (
LoggingContext.current_context()
) # type: Optional[LoggingContextOrSentinel]
if parent_context == LoggingContext.sentinel: if parent_context == LoggingContext.sentinel:
logger.warning( logger.warning(
"Starting db connection from sentinel context: metrics will be lost" "Starting db connection from sentinel context: metrics will be lost"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment