Search code examples
pythonrediscelery

Celery tasks not executed - simplest example with celery not working


I have troubles running very basic, actually the simplest celery example.

Can You guide me whether I'm doing something wrong here?

worker part:

from celery import Celery

celery = Celery('tasks', broker='redis://localhost:6379/0',backend='redis://localhost:6379/1')

@celery.task
def add(x, y):
    return x + y

and run it with: celery -A tasks worker --loglevel=INFO

then I open new terminal and type:

>>> from tasks import add
>>> result = add.delay(1,1)
>>> 

but result.ready() is always False

and in the celery worker I cannot see task that is finished only received and run.

[2022-04-01 13:07:23,434: INFO/MainProcess] Task tasks.add[b0b98051-53b3-4fec-8f83-b1f74be27cfa] received
[2022-04-01 13:07:24,304: INFO/SpawnPoolWorker-19] child process 31632 calling self.run()
[2022-04-01 13:07:24,318: INFO/SpawnPoolWorker-20] child process 4648 calling self.run()
[2022-04-01 13:07:24,322: INFO/SpawnPoolWorker-21] child process 3984 calling self.run()

enter image description here

What am I doing wrong? Thanks!


Solution

  • You are attempting to run Celery on Windows which is unsupported. https://docs.celeryq.dev/en/latest/faq.html#does-celery-support-windows

    Does Celery support Windows? Answer: No.

    Since Celery 4.x, Windows is no longer supported due to lack of resources.

    But it may still work and we are happy to accept patches.