Clean up some LoggingContext stuff (#7120)
* Pull Sentinel out of LoggingContext ... and drop a few unnecessary references to it * Factor out LoggingContext.current_context move `current_context` and `set_context` out to top-level functions. Mostly this means that I can more easily trace what's actually referring to LoggingContext, but I think it's generally neater. * move copy-to-parent into `stop` this really just makes `start` and `stop` more symetric. It also means that it behaves correctly if you manually `set_log_context` rather than using the context manager. * Replace `LoggingContext.alive` with `finished` Turn `alive` into `finished` and make it a bit better defined.
This commit is contained in:
committed by
GitHub
parent
1fcf9c6f95
commit
39230d2171
@@ -34,6 +34,7 @@ from synapse.crypto.keyring import (
|
||||
from synapse.logging.context import (
|
||||
LoggingContext,
|
||||
PreserveLoggingContext,
|
||||
current_context,
|
||||
make_deferred_yieldable,
|
||||
)
|
||||
from synapse.storage.keys import FetchKeyResult
|
||||
@@ -83,9 +84,7 @@ class KeyringTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
def check_context(self, _, expected):
|
||||
self.assertEquals(
|
||||
getattr(LoggingContext.current_context(), "request", None), expected
|
||||
)
|
||||
self.assertEquals(getattr(current_context(), "request", None), expected)
|
||||
|
||||
def test_verify_json_objects_for_server_awaits_previous_requests(self):
|
||||
key1 = signedjson.key.generate_signing_key(1)
|
||||
@@ -105,7 +104,7 @@ class KeyringTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_perspectives(**kwargs):
|
||||
self.assertEquals(LoggingContext.current_context().request, "11")
|
||||
self.assertEquals(current_context().request, "11")
|
||||
with PreserveLoggingContext():
|
||||
yield persp_deferred
|
||||
return persp_resp
|
||||
|
||||
Reference in New Issue
Block a user