diff options
author | Erik Johnston <erik@matrix.org> | 2015-05-08 16:32:18 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-05-08 16:32:18 +0100 |
commit | 476899295f5fd6cff64799bcbc84cd4bf9005e33 (patch) | |
tree | cacce7f0de3c1b694cce8c805c21c297cfbdeb76 /synapse/crypto/keyclient.py | |
parent | Merge branch 'master' of github.com:matrix-org/synapse into develop (diff) | |
download | synapse-476899295f5fd6cff64799bcbc84cd4bf9005e33.tar.xz |
Change the way we do logging contexts so that they survive divergences
Diffstat (limited to 'synapse/crypto/keyclient.py')
-rw-r--r-- | synapse/crypto/keyclient.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/synapse/crypto/keyclient.py b/synapse/crypto/keyclient.py index 4911f0896b..24f15f3154 100644 --- a/synapse/crypto/keyclient.py +++ b/synapse/crypto/keyclient.py @@ -18,7 +18,9 @@ from twisted.web.http import HTTPClient from twisted.internet.protocol import Factory from twisted.internet import defer, reactor from synapse.http.endpoint import matrix_federation_endpoint -from synapse.util.logcontext import PreserveLoggingContext +from synapse.util.logcontext import ( + preserve_context_over_fn, preserve_context_over_deferred +) import simplejson as json import logging @@ -40,11 +42,14 @@ def fetch_server_key(server_name, ssl_context_factory, path=KEY_API_V1): for i in range(5): try: - with PreserveLoggingContext(): - protocol = yield endpoint.connect(factory) - server_response, server_certificate = yield protocol.remote_key - defer.returnValue((server_response, server_certificate)) - return + protocol = yield preserve_context_over_fn( + endpoint.connect, factory + ) + server_response, server_certificate = yield preserve_context_over_deferred( + protocol.remote_key + ) + defer.returnValue((server_response, server_certificate)) + return except SynapseKeyClientError as e: logger.exception("Error getting key for %r" % (server_name,)) if e.status.startswith("4"): |