Closed Artiom-M closed 4 years ago
I would suggest to put
await asyncio.sleep(5)
just after sync in order to control the frequency of syncs.
Is there anything like this during sync_forever call?
Thanks for pointing this out and a workaround. I too have noticed rather large CPU usage increases on my homeserver from bots using this template.
Regarding the wait, /sync
requests are how bots get messags. I don't want to impose an artificial 5s delay into every response from the bot. That would make it appear quite slow.
Matrix clients already sync as often as they can. The problem here is that we're using full_state=True
, which means a matrix homeserver will answer the request immediately, even if there are 0 items to return to the client. Normally with matrix clients, the request is only completed once there is a message for the client to receive.
However, nio seems to inconsistently return messages if full_state=False
, so it looks like this may be an upstream bug. I'll try to chat to poljar and see if there's something we can do here.
Fixed in 1eacb2926e33d074578d49df263a469c391a82cc
I am using the loop as in the template code and it looks like it syncs to often. My homeserver log is filled with messages like: https://framabin.org/p/?ee3f825e469d12c8#B6hNNDtYf8AafS0Yy+hcy/wCHS5bPogwKweSbQ5wZIs=