瀏覽代碼

reduce memory use in cron by using yield_per()

Son NK 5 年之前
父節點
當前提交
84381e9635
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      cron.py

+ 1 - 1
cron.py

@@ -179,7 +179,7 @@ def stats_before(moment: Arrow) -> Stats:
         q = q.filter(~User.email.contains(ie))
         q = q.filter(~User.email.contains(ie))
 
 
     nb_spam = nb_bounced = nb_forward = nb_block = nb_reply = 0
     nb_spam = nb_bounced = nb_forward = nb_block = nb_reply = 0
-    for email_log in q:
+    for email_log in q.yield_per(500):
         if email_log.bounced:
         if email_log.bounced:
             nb_bounced += 1
             nb_bounced += 1
         elif email_log.is_spam:
         elif email_log.is_spam: