Skip to content

Commit a03c02c

Browse files
committed
Use a generator instead of a list to store the members to sync
This reduces the memory required on bot startup
1 parent e302fe2 commit a03c02c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

metricity/exts/event_listeners/startup_sync.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def sync_guild(self) -> None:
3939
await sess.execute(update(models.User).values(in_guild=False))
4040
await sess.commit()
4141

42-
users = [
42+
users = (
4343
{
4444
"id": str(user.id),
4545
"name": user.name,
@@ -54,12 +54,12 @@ async def sync_guild(self) -> None:
5454
"pending": user.pending,
5555
}
5656
for user in guild.members
57-
]
57+
)
5858

5959
user_chunks = discord.utils.as_chunks(users, 500)
6060
created = 0
6161
updated = 0
62-
total_users = len(users)
62+
total_users = len(guild.members)
6363

6464
log.info("Performing bulk upsert of %d rows in %d chunks", total_users, math.ceil(total_users / 500))
6565

0 commit comments

Comments
 (0)