diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-10-13 17:18:29 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-10-13 17:18:29 +0100 |
commit | 32d66738b0229aa7f011d203d0cb7963f950bb95 (patch) | |
tree | c91b2688f7b466ececbe40e0f91a93c5992032be /synapse/util/debug.py | |
parent | Bounce all deferreds through the reactor to make debugging easier. (diff) | |
download | synapse-32d66738b0229aa7f011d203d0cb7963f950bb95.tar.xz |
Fix pep8 warnings.
Diffstat (limited to '')
-rw-r--r-- | synapse/util/debug.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/synapse/util/debug.py b/synapse/util/debug.py index 66ac12c291..f6a5a841a4 100644 --- a/synapse/util/debug.py +++ b/synapse/util/debug.py @@ -17,13 +17,6 @@ from twisted.internet import defer, reactor from functools import wraps from synapse.util.logcontext import LoggingContext, PreserveLoggingContext -def with_logging_context(fn): - context = LoggingContext.current_context() - def restore_context_callback(x): - with PreserveLoggingContext(): - LoggingContext.thread_local.current_context = context - return fn(x) - return restore_context_callback def debug_deferreds(): """Cause all deferreds to wait for a reactor tick before running their @@ -31,6 +24,18 @@ def debug_deferreds(): a defer.inlineCallback since the code waiting on the deferred will get a chance to add an errback before the deferred runs.""" + # Helper method for retrieving and restoring the current logging context + # around a callback. + def with_logging_context(fn): + context = LoggingContext.current_context() + + def restore_context_callback(x): + with PreserveLoggingContext(): + LoggingContext.thread_local.current_context = context + return fn(x) + + return restore_context_callback + # We are going to modify the __init__ method of defer.Deferred so we # need to get a copy of the old method so we can still call it. old__init__ = defer.Deferred.__init__ @@ -65,4 +70,3 @@ def debug_deferreds(): self.addCallbacks(bounce_callback, bounce_errback) defer.Deferred.__init__ = new__init__ - |