Reputation: 6769
I am able to execute my task no problem using
scrape_adhoc_reporting([store], [types], inventory)
This is a problem though, because this task can easily take an hour. So I try to make the task async. I tried both of following:
scrape_adhoc_reporting.apply_async(args=[[store], [types], inventory])
scrape_adhoc_reporting.delay([store], [types], inventory)
Both of these methods did not work. The view just redirects as it should, but the task never gets executed. There are no errors in the error log. Any insight as to what I am doing wrong?
Edit: After looking around a little bit more, I see people talking about registering a task. Is this something I need to do?
Upvotes: 7
Views: 10729
Reputation: 276
When using asynchronous celery task in Windows normally you get an error that is fixed by setting a parameter.
i.e: With Django in the file celery.py you should:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
os.environ.setdefault('FORKED_BY_MULTIPROCESSING', '1')
<== Add this line for Windows compatibility.
This will fix the problem on Windows and does not create incompatibility problems on other systems.
Upvotes: 0
Reputation: 121
I ran in the same issue and I just solved it. MattH is right: this is due to non-running workers.
I'm using Django (1.5), Celery (3.0+) and Django-Celery on Windows. To get Celery Beat working, I followed this tutorial: http://mrtn.me/blog/2012/07/04/django-on-windows-run-celery-as-a-windows-service/ as on Windows, Beat can only be launched as a service.
However, as you, my tasks were launched but not executed. This came from a bug in the packaged version django-windows-tools (from pip).
I fixed the issue by downloading the latest version of django-windows-tools from GitHub (https://github.com/antoinemartin/django-windows-tools).
Upvotes: 4
Reputation: 38265
If you want it to be run remotely, you need a worker process running with that task loaded and a routing system configured to get the task request sent between the caller and the worker.
Have a look at the celery documentation for workers and tasks.
The code that you're running is just executing the task locally.
Upvotes: 1