diff options
author | Erik Johnston <erik@matrix.org> | 2015-03-02 13:39:22 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-03-02 13:39:22 +0000 |
commit | 4195e55ccc0f5751b13136b8c5f60686a902b79d (patch) | |
tree | d9e1596e1ecf6cfd6a3e7152a20748496a9e0890 /synapse/federation/federation_server.py | |
parent | Use contextlib.contextmanager instead of a custom class (diff) | |
parent | Merge pull request #95 from matrix-org/serialize_transaction_processing (diff) | |
download | synapse-4195e55ccc0f5751b13136b8c5f60686a902b79d.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into federation_rate_limit
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r-- | synapse/federation/federation_server.py | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index 22b9663831..bc9bac809a 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -112,17 +112,19 @@ class FederationServer(FederationBase): logger.debug("[%s] Transaction is new", transaction.transaction_id) with PreserveLoggingContext(): - dl = [] + results = [] + for pdu in pdu_list: d = self._handle_new_pdu(transaction.origin, pdu) - def handle_failure(failure): - failure.trap(FederationError) - self.send_failure(failure.value, transaction.origin) - - d.addErrback(handle_failure) - - dl.append(d) + try: + yield d + results.append({}) + except FederationError as e: + self.send_failure(e, transaction.origin) + results.append({"error": str(e)}) + except Exception as e: + results.append({"error": str(e)}) if hasattr(transaction, "edus"): for edu in [Edu(**x) for x in transaction.edus]: @@ -135,21 +137,11 @@ class FederationServer(FederationBase): for failure in getattr(transaction, "pdu_failures", []): logger.info("Got failure %r", failure) - results = yield defer.DeferredList(dl, consumeErrors=True) - - ret = [] - for r in results: - if r[0]: - ret.append({}) - else: - logger.exception(r[1]) - ret.append({"error": str(r[1].value)}) - - logger.debug("Returning: %s", str(ret)) + logger.debug("Returning: %s", str(results)) response = { "pdus": dict(zip( - (p.event_id for p in pdu_list), ret + (p.event_id for p in pdu_list), results )), } |