2012-01-24 56 views
1

我正在使用Django-Mailer-2從Django應用程序發送電子郵件。如果我通過crontab每5分鐘運行一次命令python manage.py send_mail,它將發送已添加到隊列中的所有電子郵件。Django Mailer 2 - 將通過cron運行命令將命令翻倍?

如果我一次向隊列中添加1000封電子郵件,並且每5分鐘運行一次命令python manage.py send_mail,那麼每5分鐘會啓動一次添加線程以發送隊列中的電子郵件嗎?

回答

3

不,它使用鎖定文件,如果前一個send_mail正在運行,將退出。

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