Celery Received unregistered task of type (run example)

后端 未结 30 1845
旧时难觅i
旧时难觅i 2020-11-28 04:42

I\'m trying to run example from Celery documentation.

I run: celeryd --loglevel=INFO

/usr/local/lib/python2.7/dist-packages/celery/loade         


        
相关标签:
30条回答
  • 2020-11-28 05:10

    In my case the error was because one container created files in a folder that were mounted on the host file-system with docker-compose.

    I just had to do remove the files created by the container on the host system and I was able to launch my project again.

    sudo rm -Rf foldername

    (I had to use sudo because the files were owned by the root user)

    Docker version: 18.03.1

    0 讨论(0)
  • 2020-11-28 05:10
    app = Celery(__name__, broker=app.config['CELERY_BROKER'], 
    backend=app.config['CELERY_BACKEND'], include=['util.xxxx', 'util.yyyy'])
    
    0 讨论(0)
  • 2020-11-28 05:11

    I had the same problem: The reason of "Received unregistered task of type.." was that celeryd service didn't find and register the tasks on service start (btw their list is visible when you start ./manage.py celeryd --loglevel=info ).

    These tasks should be declared in CELERY_IMPORTS = ("tasks", ) in settings file.
    If you have a special celery_settings.py file it has to be declared on celeryd service start as --settings=celery_settings.py as digivampire wrote.

    0 讨论(0)
  • 2020-11-28 05:12

    I had the same problem running tasks from Celery Beat. Celery doesn't like relative imports so in my celeryconfig.py, I had to explicitly set the full package name:

    app.conf.beat_schedule = {
       'add-every-30-seconds': {
            'task': 'full.path.to.add',
            'schedule': 30.0,
            'args': (16, 16)
        },
    }
    
    0 讨论(0)
  • 2020-11-28 05:13

    Celery doesn't support relative imports so in my celeryconfig.py, you need absolute import.

    CELERYBEAT_SCHEDULE = {
            'add_num': {
                'task': 'app.tasks.add_num.add_nums',
                'schedule': timedelta(seconds=10),
                'args': (1, 2)
            }
    }
    
    0 讨论(0)
  • 2020-11-28 05:14

    I had this problem mysteriously crop up when I added some signal handling to my django app. In doing so I converted the app to use an AppConfig, meaning that instead of simply reading as 'booking' in INSTALLED_APPS, it read 'booking.app.BookingConfig'.

    Celery doesn't understand what that means, so I added, INSTALLED_APPS_WITH_APPCONFIGS = ('booking',) to my django settings, and modified my celery.py from

    app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
    

    to

    app.autodiscover_tasks(
        lambda: settings.INSTALLED_APPS + settings.INSTALLED_APPS_WITH_APPCONFIGS
    )
    
    0 讨论(0)
提交回复
热议问题