def handle(self, *args, **options): forever = options.get('forever') while True: try: process() except KeyboardInterrupt: return except: if settings.DEBUG: raise else: import traceback mail_admins(__name__, traceback.format_exc()) if not forever: return
def test_add_mail(self): self.assertEquals(len(mail.outbox), 0) self.assertEquals(MailerMessage.objects.count(), 0) add_mail('subject2', 'body2', '*****@*****.**') self.assertEquals(len(mail.outbox), 0) self.assertEquals(MailerMessage.objects.count(), 1) process() self.assertEquals(len(mail.outbox), 1) self.assertEquals(MailerMessage.objects.count(), 1) self.assertEquals(mail.outbox[0].subject, u'subject2') self.assertEquals(mail.outbox[0].body, u'body2')
def process_mailqueue(): logging.info('start celery task "mailqueue.process"') process()