mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-05 21:01:08 -05:00
client: Simplify the sync logic.
This commit is contained in:
parent
6092e27748
commit
ba09f77cb6
@ -397,51 +397,27 @@ class PanClient(AsyncClient):
|
||||
|
||||
self.history_fetcher_task = loop.create_task(self.fetcher_loop())
|
||||
|
||||
task = loop.create_task(self.sync_loop())
|
||||
self.task = task
|
||||
|
||||
return task
|
||||
|
||||
async def sync_loop(self):
|
||||
timeout = 30000
|
||||
|
||||
sync_filter = {
|
||||
"room": {
|
||||
"state": {"lazy_load_members": True}
|
||||
}
|
||||
}
|
||||
|
||||
next_batch = self.pan_store.load_token(
|
||||
self.server_name,
|
||||
self.user_id
|
||||
)
|
||||
next_batch = self.pan_store.load_token(self.server_name, self.user_id)
|
||||
|
||||
# We don't store any room state so initial sync needs to be with the
|
||||
# full_state parameter. Subsequent ones are normal.
|
||||
while True:
|
||||
try:
|
||||
response = await self.sync(
|
||||
sync_filter=sync_filter,
|
||||
full_state=True,
|
||||
since=next_batch,
|
||||
)
|
||||
task = loop.create_task(
|
||||
self.sync_forever(
|
||||
timeout,
|
||||
sync_filter,
|
||||
full_state=True,
|
||||
since=next_batch
|
||||
)
|
||||
)
|
||||
self.task = task
|
||||
|
||||
if isinstance(response, SyncResponse):
|
||||
await self.sync_tasks(response)
|
||||
break
|
||||
else:
|
||||
await asyncio.sleep(3)
|
||||
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
|
||||
except ClientConnectionError:
|
||||
try:
|
||||
await asyncio.sleep(3)
|
||||
except asyncio.CancelledError:
|
||||
return
|
||||
|
||||
await self.sync_forever(timeout, sync_filter)
|
||||
return task
|
||||
|
||||
async def start_sas(self, message, device):
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user