Celery Queue 似乎没有注册我的任务

发布于 2024-09-27 20:35:31 字数 2214 浏览 2 评论 0原文

我正在使用 Django 和 Celery 与 RabbitMQ 进行通信。我已经注册了所有任务,并将它们放入我的设置文件中的 CELERY_IMPORTS 元组中。当我运行任务时,收到“未注册”错误消息。

# tail -f /var/log/celeryd.log 
    . logfile -> /var/log/celeryd.log@INFO
    . events -> OFF
    . beat -> OFF
    . tasks ->
    . apps.contact.tasks.emailContact
    . apps.declaration.tasks.MailChimpSignup
    . apps.questions.tasks.emailQuestionTask
    . queued_storage.tasks.SaveToRemoteTask
[2010-10-19 17:53:44,958: INFO/PoolWorker-1] child process calling self.run()
[2010-10-19 17:53:44,971: WARNING/MainProcess] [email protected] has started.


[2010-10-19 17:54:03,962: ERROR/MainProcess] Unknown task ignored: "Task of kind 'apps.declaration.tasks.MailChimpSignup' is not registered, please make sure it's imported.": {'retries': 0, 'task': 'apps.declaration.tasks.MailChimpSignup', 'args': [], 'eta': None, 'kwargs': {'email': u'[email protected]'}, 'id': '919c6030-70b1-43e6-87f5-907fa0f52c08'}

我的任务定义如下:

class MailChimpSignup(Task):
    def run(self, email, **kwargs):
        """
        This will register the declaration signer on mail chimp.
        """
        logger = self.get_logger(**kwargs)
        logger.info("Processed mailchimp signup for %s" % email)
        chimp = chimpy.Connection(settings.MAILCHIMP_API_KEY)

        try:
            chimp.list_member_info(settings.MAILCHIMP_LIST_ID, email)
        except ChimpyException:
            try:
                x = chimp.list_subscribe(
                        settings.MAILCHIMP_LIST_ID,
                        email,
                        {
                        #    'FNAME': self.first_name,
                        #    'LNAME': self.last_name,
                        },
                        email_type='HTML',
                        double_optin = False,
                )
            except ChimpyException:
                return False
        return True
tasks.register(MailChimpSignup)

I'm using Django and Celery to communicate with RabbitMQ. I've registered all of the tasks, and put them in the CELERY_IMPORTS tuple in my settings file. When I run a task, I get the "not registered" error message.

# tail -f /var/log/celeryd.log 
    . logfile -> /var/log/celeryd.log@INFO
    . events -> OFF
    . beat -> OFF
    . tasks ->
    . apps.contact.tasks.emailContact
    . apps.declaration.tasks.MailChimpSignup
    . apps.questions.tasks.emailQuestionTask
    . queued_storage.tasks.SaveToRemoteTask
[2010-10-19 17:53:44,958: INFO/PoolWorker-1] child process calling self.run()
[2010-10-19 17:53:44,971: WARNING/MainProcess] [email protected] has started.


[2010-10-19 17:54:03,962: ERROR/MainProcess] Unknown task ignored: "Task of kind 'apps.declaration.tasks.MailChimpSignup' is not registered, please make sure it's imported.": {'retries': 0, 'task': 'apps.declaration.tasks.MailChimpSignup', 'args': [], 'eta': None, 'kwargs': {'email': u'[email protected]'}, 'id': '919c6030-70b1-43e6-87f5-907fa0f52c08'}

Heres what my task definition looks like:

class MailChimpSignup(Task):
    def run(self, email, **kwargs):
        """
        This will register the declaration signer on mail chimp.
        """
        logger = self.get_logger(**kwargs)
        logger.info("Processed mailchimp signup for %s" % email)
        chimp = chimpy.Connection(settings.MAILCHIMP_API_KEY)

        try:
            chimp.list_member_info(settings.MAILCHIMP_LIST_ID, email)
        except ChimpyException:
            try:
                x = chimp.list_subscribe(
                        settings.MAILCHIMP_LIST_ID,
                        email,
                        {
                        #    'FNAME': self.first_name,
                        #    'LNAME': self.last_name,
                        },
                        email_type='HTML',
                        double_optin = False,
                )
            except ChimpyException:
                return False
        return True
tasks.register(MailChimpSignup)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆追雨的时光 2024-10-04 20:35:31

奇怪的。它似乎确实有正确的名字。

您可以尝试手动为任务分配名称吗?

@task(name="MailChimpSignup")
def ...

Strange. It does seem to have the right names.

Could you try manually assigning a name to the task?

@task(name="MailChimpSignup")
def ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文