소스 검색

Do not call getfullargspec on every call. (#16589)

getfullargspec is relatively expensive and the results will
not change between calls, so precalculate it outside the
wrapper.
tags/v1.97.0rc1
Patrick Cloke 6 달 전
committed by GitHub
부모
커밋
ed1b879576
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
2개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. +1
    -0
      changelog.d/16589.misc
  2. +5
    -2
      synapse/logging/opentracing.py

+ 1
- 0
changelog.d/16589.misc 파일 보기

@@ -0,0 +1 @@
Improve performance when using opentracing.

+ 5
- 2
synapse/logging/opentracing.py 파일 보기

@@ -1019,11 +1019,14 @@ def tag_args(func: Callable[P, R]) -> Callable[P, R]:
if not opentracing:
return func

# getfullargspec is somewhat expensive, so ensure it is only called a single
# time (the function signature shouldn't change anyway).
argspec = inspect.getfullargspec(func)

@contextlib.contextmanager
def _wrapping_logic(
func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
_func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
) -> Generator[None, None, None]:
argspec = inspect.getfullargspec(func)
# We use `[1:]` to skip the `self` object reference and `start=1` to
# make the index line up with `argspec.args`.
#


불러오는 중...
취소
저장