Django Mailer 2 -- will running the command via cron double up the commands?

558 views Asked by At

I am using Django-Mailer-2 to send email from a Django App. If I have the command python manage.py send_mail run every 5 minutes via the crontab, it will send any emails that have been added to the queue.

If I add 1,000 emails to the queue all at once and the command python manage.py send_mail is run every 5 minutes, will addition threads be started every 5 minutes to send the emails on the queue?

1

There are 1 answers

0
Yuji 'Tomita' Tomita On BEST ANSWER

No, it uses a lock file and will quit if a previous send_mail is running.

https://github.com/SmileyChris/django-mailer-2/blob/master/django_mailer/engine.py

try:
    # lockfile has a bug dealing with a negative LOCK_WAIT_TIMEOUT (which
    # is the default if it's not provided) systems which use a LinkFileLock
    # so ensure that it is never a negative number.
    lock.acquire(settings.LOCK_WAIT_TIMEOUT or 0)
    #lock.acquire(settings.LOCK_WAIT_TIMEOUT)
except AlreadyLocked:
    logger.debug("Lock already in place. Exiting.")
    return
except LockTimeout:
    logger.debug("Waiting for the lock timed out. Exiting.")
    return