【问题标题】:Django Mailer 2 -- will running the command via cron double up the commands?Django Mailer 2——通过 cron 运行命令会加倍命令吗?
【发布时间】:2012-02-18 03:12:11
【问题描述】:

我正在使用 Django-Mailer-2 从 Django 应用程序发送电子邮件。如果我通过crontab 每5 分钟运行一次命令python manage.py send_mail,它将发送已添加到队列中的所有电子邮件。

如果我一次将 1,000 封电子邮件添加到队列中,并且每 5 分钟运行一次命令 python manage.py send_mail,是否会每 5 分钟启动添加线程以发送队列中的电子邮件?

【问题讨论】:

    标签: django django-mailer


    【解决方案1】:

    不,它使用锁定文件,如果之前的 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      • 1970-01-01
      • 2015-04-02
      • 1970-01-01
      • 2016-07-03
      • 1970-01-01
      • 2019-09-05
      相关资源
      最近更新 更多