Easy type hints in synapse.logging.opentracing (#12894)

This commit is contained in:
David Robertson 2022-05-27 11:17:33 +01:00 committed by GitHub
parent f1605b7447
commit 3503f42741
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 57 deletions

View file

@ -14,6 +14,7 @@
import logging
import threading
from contextlib import nullcontext
from functools import wraps
from types import TracebackType
from typing import (
@ -41,11 +42,7 @@ from synapse.logging.context import (
LoggingContext,
PreserveLoggingContext,
)
from synapse.logging.opentracing import (
SynapseTags,
noop_context_manager,
start_active_span,
)
from synapse.logging.opentracing import SynapseTags, start_active_span
from synapse.metrics._types import Collector
if TYPE_CHECKING:
@ -238,7 +235,7 @@ def run_as_background_process(
f"bgproc.{desc}", tags={SynapseTags.REQUEST_ID: str(context)}
)
else:
ctx = noop_context_manager()
ctx = nullcontext()
with ctx:
return await func(*args, **kwargs)
except Exception: