mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-04 05:38:57 +01:00
Parellelize initial sync
This commit is contained in:
parent
25d2914fba
commit
1ec6fa98c9
1 changed files with 8 additions and 2 deletions
|
@ -274,7 +274,8 @@ class MessageHandler(BaseHandler):
|
||||||
if limit is None:
|
if limit is None:
|
||||||
limit = 10
|
limit = 10
|
||||||
|
|
||||||
for event in room_list:
|
@defer.inlineCallbacks
|
||||||
|
def handle_room(event):
|
||||||
d = {
|
d = {
|
||||||
"room_id": event.room_id,
|
"room_id": event.room_id,
|
||||||
"membership": event.membership,
|
"membership": event.membership,
|
||||||
|
@ -290,7 +291,7 @@ class MessageHandler(BaseHandler):
|
||||||
rooms_ret.append(d)
|
rooms_ret.append(d)
|
||||||
|
|
||||||
if event.membership != Membership.JOIN:
|
if event.membership != Membership.JOIN:
|
||||||
continue
|
return
|
||||||
try:
|
try:
|
||||||
messages, token = yield self.store.get_recent_events_for_room(
|
messages, token = yield self.store.get_recent_events_for_room(
|
||||||
event.room_id,
|
event.room_id,
|
||||||
|
@ -321,6 +322,11 @@ class MessageHandler(BaseHandler):
|
||||||
except:
|
except:
|
||||||
logger.exception("Failed to get snapshot")
|
logger.exception("Failed to get snapshot")
|
||||||
|
|
||||||
|
yield defer.gatherResults(
|
||||||
|
[handle_room(e) for e in room_list],
|
||||||
|
consumeErrors=True
|
||||||
|
)
|
||||||
|
|
||||||
ret = {
|
ret = {
|
||||||
"rooms": rooms_ret,
|
"rooms": rooms_ret,
|
||||||
"presence": presence,
|
"presence": presence,
|
||||||
|
|
Loading…
Reference in a new issue