mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:06:08 -04:00
Add type hints to the logging context code. (#8939)
This commit is contained in:
parent
9dde9c9f01
commit
06fefe0bb1
4 changed files with 47 additions and 22 deletions
|
@ -42,7 +42,6 @@ from synapse.api.errors import StoreError
|
|||
from synapse.config.database import DatabaseConnectionConfig
|
||||
from synapse.logging.context import (
|
||||
LoggingContext,
|
||||
LoggingContextOrSentinel,
|
||||
current_context,
|
||||
make_deferred_yieldable,
|
||||
)
|
||||
|
@ -671,12 +670,15 @@ class DatabasePool:
|
|||
Returns:
|
||||
The result of func
|
||||
"""
|
||||
parent_context = current_context() # type: Optional[LoggingContextOrSentinel]
|
||||
if not parent_context:
|
||||
curr_context = current_context()
|
||||
if not curr_context:
|
||||
logger.warning(
|
||||
"Starting db connection from sentinel context: metrics will be lost"
|
||||
)
|
||||
parent_context = None
|
||||
else:
|
||||
assert isinstance(curr_context, LoggingContext)
|
||||
parent_context = curr_context
|
||||
|
||||
start_time = monotonic_time()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue