defer.gatherResults rather than doing all the pokes in series
This commit is contained in:
parent
fa129ce5b5
commit
25cd5bb697
|
@ -123,10 +123,17 @@ class PusherPool:
|
||||||
users_affected = yield self.store.get_push_action_users_in_range(
|
users_affected = yield self.store.get_push_action_users_in_range(
|
||||||
min_stream_id, max_stream_id
|
min_stream_id, max_stream_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
deferreds = []
|
||||||
|
|
||||||
for u in users_affected:
|
for u in users_affected:
|
||||||
if u in self.pushers:
|
if u in self.pushers:
|
||||||
for p in self.pushers[u].values():
|
for p in self.pushers[u].values():
|
||||||
yield p.on_new_notifications(min_stream_id, max_stream_id)
|
deferreds.append(
|
||||||
|
p.on_new_notifications(min_stream_id, max_stream_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
yield defer.gatherResults(deferreds)
|
||||||
except:
|
except:
|
||||||
logger.exception("Exception in pusher on_new_notifications")
|
logger.exception("Exception in pusher on_new_notifications")
|
||||||
|
|
||||||
|
@ -141,10 +148,17 @@ class PusherPool:
|
||||||
)
|
)
|
||||||
# This returns a tuple, user_id is at index 3
|
# This returns a tuple, user_id is at index 3
|
||||||
users_affected = set([r[3] for r in updated_receipts])
|
users_affected = set([r[3] for r in updated_receipts])
|
||||||
|
|
||||||
|
deferreds = []
|
||||||
|
|
||||||
for u in users_affected:
|
for u in users_affected:
|
||||||
if u in self.pushers:
|
if u in self.pushers:
|
||||||
for p in self.pushers[u].values():
|
for p in self.pushers[u].values():
|
||||||
yield p.on_new_receipts(min_stream_id, max_stream_id)
|
deferreds.append(
|
||||||
|
p.on_new_receipts(min_stream_id, max_stream_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
yield defer.gatherResults(deferreds)
|
||||||
except:
|
except:
|
||||||
logger.exception("Exception in pusher on_new_receipts")
|
logger.exception("Exception in pusher on_new_receipts")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue