@@ -117,8 +117,7 @@ def __init__(self, copy_from: "Optional[ContextResourceUsage]" = None) -> None:
117
117
"""Create a new ContextResourceUsage
118
118
119
119
Args:
120
- copy_from (ContextResourceUsage|None): if not None, an object to
121
- copy stats from
120
+ copy_from: if not None, an object to copy stats from
122
121
"""
123
122
if copy_from is None :
124
123
self .reset ()
@@ -162,7 +161,7 @@ def __iadd__(self, other: "ContextResourceUsage") -> "ContextResourceUsage":
162
161
"""Add another ContextResourceUsage's stats to this one's.
163
162
164
163
Args:
165
- other (ContextResourceUsage) : the other resource usage object
164
+ other: the other resource usage object
166
165
"""
167
166
self .ru_utime += other .ru_utime
168
167
self .ru_stime += other .ru_stime
@@ -342,7 +341,7 @@ def current_context(cls) -> LoggingContextOrSentinel:
342
341
called directly.
343
342
344
343
Returns:
345
- LoggingContext: the current logging context
344
+ The current logging context
346
345
"""
347
346
warnings .warn (
348
347
"synapse.logging.context.LoggingContext.current_context() is deprecated "
@@ -362,7 +361,8 @@ def set_current_context(
362
361
called directly.
363
362
364
363
Args:
365
- context(LoggingContext): The context to activate.
364
+ context: The context to activate.
365
+
366
366
Returns:
367
367
The context that was previously active
368
368
"""
@@ -474,8 +474,7 @@ def get_resource_usage(self) -> ContextResourceUsage:
474
474
"""Get resources used by this logcontext so far.
475
475
476
476
Returns:
477
- ContextResourceUsage: a *copy* of the object tracking resource
478
- usage so far
477
+ A *copy* of the object tracking resource usage so far
479
478
"""
480
479
# we always return a copy, for consistency
481
480
res = self ._resource_usage .copy ()
@@ -663,7 +662,8 @@ def current_context() -> LoggingContextOrSentinel:
663
662
def set_current_context (context : LoggingContextOrSentinel ) -> LoggingContextOrSentinel :
664
663
"""Set the current logging context in thread local storage
665
664
Args:
666
- context(LoggingContext): The context to activate.
665
+ context: The context to activate.
666
+
667
667
Returns:
668
668
The context that was previously active
669
669
"""
@@ -700,7 +700,7 @@ def nested_logging_context(suffix: str) -> LoggingContext:
700
700
suffix: suffix to add to the parent context's 'name'.
701
701
702
702
Returns:
703
- LoggingContext: new logging context.
703
+ A new logging context.
704
704
"""
705
705
curr_context = current_context ()
706
706
if not curr_context :
@@ -898,20 +898,19 @@ def defer_to_thread(
898
898
on it.
899
899
900
900
Args:
901
- reactor (twisted.internet.base.ReactorBase): The reactor in whose main thread
902
- the Deferred will be invoked, and whose threadpool we should use for the
903
- function.
901
+ reactor: The reactor in whose main thread the Deferred will be invoked,
902
+ and whose threadpool we should use for the function.
904
903
905
904
Normally this will be hs.get_reactor().
906
905
907
- f (callable) : The function to call.
906
+ f: The function to call.
908
907
909
908
args: positional arguments to pass to f.
910
909
911
910
kwargs: keyword arguments to pass to f.
912
911
913
912
Returns:
914
- Deferred: A Deferred which fires a callback with the result of `f`, or an
913
+ A Deferred which fires a callback with the result of `f`, or an
915
914
errback if `f` throws an exception.
916
915
"""
917
916
return defer_to_threadpool (reactor , reactor .getThreadPool (), f , * args , ** kwargs )
@@ -939,20 +938,20 @@ def defer_to_threadpool(
939
938
on it.
940
939
941
940
Args:
942
- reactor (twisted.internet.base.ReactorBase) : The reactor in whose main thread
943
- the Deferred will be invoked. Normally this will be hs.get_reactor().
941
+ reactor: The reactor in whose main thread the Deferred will be invoked.
942
+ Normally this will be hs.get_reactor().
944
943
945
- threadpool (twisted.python.threadpool.ThreadPool) : The threadpool to use for
946
- running `f`. Normally this will be hs.get_reactor().getThreadPool().
944
+ threadpool: The threadpool to use for running `f`. Normally this will be
945
+ hs.get_reactor().getThreadPool().
947
946
948
- f (callable) : The function to call.
947
+ f: The function to call.
949
948
950
949
args: positional arguments to pass to f.
951
950
952
951
kwargs: keyword arguments to pass to f.
953
952
954
953
Returns:
955
- Deferred: A Deferred which fires a callback with the result of `f`, or an
954
+ A Deferred which fires a callback with the result of `f`, or an
956
955
errback if `f` throws an exception.
957
956
"""
958
957
curr_context = current_context ()
0 commit comments