Exemple #1
0
 def handle(self, *args, **options):
     while True:
         try:
             clean()
         except KeyboardInterrupt:
             return
         except:
             if settings.DEBUG:
                 raise
             else:
                 import traceback
                 mail_admins(__name__, traceback.format_exc())
Exemple #2
0
    def test_clean(self):
        self.assertEquals(MailerMessage.objects.count(), 0)
        add_mail('subject3', 'body3', '*****@*****.**')
        self.assertEquals(MailerMessage.objects.count(), 1)

        MailerMessage.objects.all().update(
            sent_datetime=timezone.now() - datetime.timedelta(10),
        )

        clean()
        self.assertEquals(MailerMessage.objects.count(), 1)

        try:
            conf.MAILQUEUE_ARCHIVE_LIFETIME_DAYS = 11
            clean()
            self.assertEquals(MailerMessage.objects.count(), 1)
            conf.MAILQUEUE_ARCHIVE_LIFETIME_DAYS = 1
            clean()
            self.assertEquals(MailerMessage.objects.count(), 0)
        finally:
            conf.MAILQUEUE_ARCHIVE_LIFETIME_DAYS = 0
Exemple #3
0
def clean_mailqueue():
    logging.info('start celery task "mailqueue.clean"')
    clean()