1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Use generator in Mailbox.get_mail to limit memory leak (#149)

* Use generator in Mailbox.get_mail to limit memory leak

* Fix generator support in tests/base.py
This commit is contained in:
Adam Dobrawy 2018-03-09 19:09:45 +01:00 committed by Adam Coddington
parent a299a00506
commit 2b2bdb9825
4 changed files with 24 additions and 14 deletions

View file

@ -408,17 +408,16 @@ class Mailbox(models.Model):
new_mail = []
connection = self.get_connection()
if not connection:
return new_mail
return
for message in connection.get_message(condition):
msg = self.process_incoming_message(message)
if not msg is None:
new_mail.append(msg)
yield msg
self.last_polling = now()
if django.VERSION >= (1, 5): # Django 1.5 introduces update_fields
self.save(update_fields=['last_polling'])
else:
self.save()
return new_mail
def __str__(self):
return self.name