summary refs log tree commit diff
path: root/synapse/logging/scopecontextmanager.py
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2024-12-20 10:57:59 +0000
committerGitHub <noreply@github.com>2024-12-20 10:57:59 +0000
commitd69c00b5a19ba45645665afa532421b25c74407a (patch)
treebda017e2da19ec213aaccd5d4fd8a95b297efaab /synapse/logging/scopecontextmanager.py
parentRemove support for PostgreSQL 11 and 12 (#18034) (diff)
downloadsynapse-d69c00b5a19ba45645665afa532421b25c74407a.tar.xz
Stop using twisted.internet.defer.returnValue (#18020)
`defer.returnValue` was only needed in Python 2; in Python 3, a simple
`return` is fine.

`twisted.internet.defer.returnValue` is deprecated as of Twisted 24.7.0.

Most uses of `returnValue` in synapse were removed a while back; this
cleans up some remaining bits.
Diffstat (limited to 'synapse/logging/scopecontextmanager.py')
-rw-r--r--synapse/logging/scopecontextmanager.py19
1 files changed, 1 insertions, 18 deletions
diff --git a/synapse/logging/scopecontextmanager.py b/synapse/logging/scopecontextmanager.py

index 581e6d6411..feaadc4d87 100644 --- a/synapse/logging/scopecontextmanager.py +++ b/synapse/logging/scopecontextmanager.py
@@ -20,13 +20,10 @@ # import logging -from types import TracebackType -from typing import Optional, Type +from typing import Optional from opentracing import Scope, ScopeManager, Span -import twisted - from synapse.logging.context import ( LoggingContext, current_context, @@ -112,9 +109,6 @@ class _LogContextScope(Scope): """ A custom opentracing scope, associated with a LogContext - * filters out _DefGen_Return exceptions which arise from calling - `defer.returnValue` in Twisted code - * When the scope is closed, the logcontext's active scope is reset to None. and - if enter_logcontext was set - the logcontext is finished too. """ @@ -146,17 +140,6 @@ class _LogContextScope(Scope): self._finish_on_close = finish_on_close self._enter_logcontext = enter_logcontext - def __exit__( - self, - exc_type: Optional[Type[BaseException]], - value: Optional[BaseException], - traceback: Optional[TracebackType], - ) -> None: - if exc_type == twisted.internet.defer._DefGen_Return: - # filter out defer.returnValue() calls - exc_type = value = traceback = None - super().__exit__(exc_type, value, traceback) - def __str__(self) -> str: return f"Scope<{self.span}>"