Skip to content Skip to sidebar Skip to footer

Django Celery Cannot Query Postgres Db Inside Task

In my celery task I try to query my postgres db. But I always get following error: task.py @shared_task(bind=True) def ImportFiles(self, activity_file_list, user_id_list,activityf

Solution 1:

I found a solution for windows: I started my celery with following command:

celery -A geodjango.celery worker --loglevel=info --pool=eventlet

The problem seems the --pool=eventlet --> if I change pool to solo it works. Following command works now and I can make my postgres queries.

celery -A geodjango.celery worker --loglevel=info --pool=solo

I'm not an expert, I think I saw --pool=eventlet in a tutorial so I used that. But with --pool=solo it works.

Here I found an article about the different pool options, maybe it also helps someone else: https://www.distributedpython.com/2018/10/26/celery-execution-pool/

Post a Comment for "Django Celery Cannot Query Postgres Db Inside Task"