Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Process transactions serially. #95

Merged
merged 2 commits into from
Mar 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,19 @@ def on_incoming_transaction(self, transaction_data):
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]:
Expand All @@ -135,21 +137,11 @@ def handle_failure(failure):
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
)),
}

Expand Down