[Fixed]-RuntimeError: 'list' must be None or a list, not <class 'str'> while trying to start celery worker

40👍

This is how I solved the problem:

I saw that one of my apps was missing __init__.py, which caused problem with app.autodiscover_tasks(settings.INSTALLED_APPS)

I added the missing __init__.py and celery worker started without any issues

4👍

This error is raised by the Celery autodiscover_tasks when it cannot load one of your INSTALLED_APPS for some reason. In my case it was a directory with tasks.py file but other app files (models.py etc) missing because of an incomplete Git commit.

1👍

First problem – I believe the line should actually be

app.autodiscover_tasks(settings.INSTALLED_APPS)

Why did you use a lambda?

The second traceback – in miscellaneous/middleware.py you are invoking a celery task that passes a wsgiref.util.FileWrapper object – however you are using the JSON serializer which cannot serialize object instances – you’ll need to use the pickle serializer instead.

See the relevant section in the docs.

Leave a comment