hello I want to use celery tasks in my Django project and I try to follow this very good tutorial from Mr.Vitor Freitas.
but in my case and if try to run it that tutorial project i don't get results back the functions don't execute and in my case and in tutorial(i take message to wait and refresh and nothing after refresh). Any idea Why ? I think so the problem maybe is in RABBITQM server ?some configuration ? Just install Erlang(otp_win64_20.1.exe) and after RabbitMQ(rabbitmq-server-3.6.12.exe) here example code : settings.py CELERY_BROKER_URL = 'amqp://localhost' celery.py from __future__ import absolute_import import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') app = Celery('mysite') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() tasks.py import string from django.contrib.auth.models import User from django.utils.crypto import get_random_string from celery import shared_task @shared_task def create_random_user_accounts(total): for i in range(total): username = 'user_{}'.format(get_random_string(10, string.ascii_letters)) email = '{}@example.com'.format(username) password = get_random_string(50) User.objects.create_user(username=username, email=email, password=password) return '{} random users created with success!'.format(total) _ _init_ _.py from .celery import app as celery_app __all__ = ['celery_app'] views.py from django.contrib.auth.models import User from django.contrib import messages from django.views.generic import TemplateView from django.views.generic.list import ListView from django.views.generic.edit import FormView from django.shortcuts import redirect from .forms import GenerateRandomUserForm from .tasks import create_random_user_accounts class UsersListView(ListView): template_name = 'core/users_list.html' model = User class GenerateRandomUserView(FormView): template_name = 'core/generate_random_users.html' form_class = GenerateRandomUserForm def form_valid(self, form): total = form.cleaned_data.get('total') create_random_user_accounts.delay(total) messages.success(self.request, 'We are generating your random users! Wait a moment and refresh this page.') return redirect('users_list') here details after cd my project path > celery -A mysite worker -l info : C:\Windows\System32>cd C:\Users\username\Desktop\django-celery-example-master C:\Users\username\Desktop\django-celery-example-master>celery -A mysite worker -l info -------------- celery@pc name v4.1.0 (latentcall) ---- **** ----- --- * *** * -- Windows-8-6.2.9200 2017-10-29 18:10:24 -- * - **** --- - ** ---------- [config] - ** ---------- .> app: mysite:0x404e5c0 - ** ---------- .> transport: amqp://guest:**@localhost:5672// - ** ---------- .> results: disabled:// - *** --- * --- .> concurrency: 4 (prefork) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> celery exchange=celery(direct) key=celery [tasks] . mysite.core.tasks.create_random_user_accounts [2017-10-29 18:10:24,596: CRITICAL/MainProcess] Unrecoverable error: TypeError('must be integer<K>, not _subprocess_handle',) Traceback (most recent call last): File "C:\Python27\lib\site-packages\celery\worker\worker.py", line 203, in start self.blueprint.start(self) File "C:\Python27\lib\site-packages\celery\bootsteps.py", line 119, in start step.start(parent) File "C:\Python27\lib\site-packages\celery\bootsteps.py", line 370, in start return self.obj.start() File "C:\Python27\lib\site-packages\celery\concurrency\base.py", line 131, in start self.on_start() File "C:\Python27\lib\site-packages\celery\concurrency\prefork.py", line 112, in on_start **self.options) File "C:\Python27\lib\site-packages\billiard\pool.py", line 1007, in __init__ self._create_worker_process(i) File "C:\Python27\lib\site-packages\billiard\pool.py", line 1116, in _create_worker_process w.start() File "C:\Python27\lib\site-packages\billiard\process.py", line 124, in start self._popen = self._Popen(self) File "C:\Python27\lib\site-packages\billiard\context.py", line 383, in _Popen return Popen(process_obj) File "C:\Python27\lib\site-packages\billiard\popen_spawn_win32.py", line 64, in __init__ _winapi.CloseHandle(ht) TypeError: must be integer<K>, not _subprocess_handle Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Python27\lib\site-packages\billiard\spawn.py", line 159, in spawn_main new_handle = steal_handle(parent_pid, pipe_handle) File "C:\Python27\lib\site-packages\billiard\reduction.py", line 126, in steal_handle _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE) WindowsError: [Error 6] -- https://mail.python.org/mailman/listinfo/python-list