2

I made a Celery app according to a tutorial in this link, but I just some errors. After googling I downgraded to Celery version 3.1.25, claimed to be the last version supporting windows. But the errors I get remain the same. What is the problem?

# tasks.py
from celery import Celery

app = Celery('tasks', backend='amqp', broker='amqp://')

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

@app.task(ignore_result=True)
def print_hello():
    print('hello there')

@app.task
def gen_prime(x):
    multiples = []
    results = []
    for i in range(2, x+1):
        if i not in multiples:
            results.append(i)
            for j in range(i*i, x+1, i):
                multiples.append(j)
    return results

The error message I get on celery running command prompt:

C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')

-------------- celery@pc v4.2.1 (windowlicker)
---- **** -----
--- * ***  * -- Windows-10-10.0.17134-SP0 2018-1-28 08:19:41
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         tasks:0x262e454cba8
- ** ---------- .> transport:   amqp://guest:**@localhost:5672//
- ** ---------- .> results:     amqp://
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: ON
--- ***** -----
-------------- [queues]
                .> celery           exchange=celery(direct) key=celery


[tasks]
. tasks.add
. tasks.gen_prime
. tasks.print_hello

[2018-1-28 08:19:41,369: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2018-1-28 08:19:41,490: INFO/MainProcess] mingle: searching for neighbors
[2018-1-28 08:19:42,676: INFO/SpawnPoolWorker-5] child process 5904 calling self.run()
[2018-1-28 08:19:42,685: INFO/SpawnPoolWorker-1] child process 15432 calling self.run()
[2018-1-28 08:19:42,688: WARNING/SpawnPoolWorker-5] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')
[2018-1-28 08:19:42,690: INFO/SpawnPoolWorker-3] child process 9580 calling self.run()
[2018-1-28 08:19:42,697: WARNING/SpawnPoolWorker-1] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')
[2018-1-28 08:19:42,700: INFO/SpawnPoolWorker-2] child process 15660 calling self.run()
[2018-1-28 08:19:42,703: WARNING/SpawnPoolWorker-3] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')
[2018-1-28 08:19:42,710: WARNING/SpawnPoolWorker-2] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')
[2018-1-28 08:19:42,724: INFO/SpawnPoolWorker-7] child process 2612 calling self.run()
[2018-1-28 08:19:42,724: INFO/SpawnPoolWorker-6] child process 15192 calling self.run()
[2018-1-28 08:19:42,725: INFO/SpawnPoolWorker-4] child process 5276 calling self.run()
[2018-1-28 08:19:42,731: INFO/SpawnPoolWorker-8] child process 16112 calling self.run()
[2018-1-28 08:19:42,733: WARNING/SpawnPoolWorker-6] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
[2018-1-28 08:19:42,733: WARNING/SpawnPoolWorker-7] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.     Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')

[2018-1-28 08:19:42,734: WARNING/SpawnPoolWorker-4] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')
[2018-1-28 08:19:42,739: WARNING/SpawnPoolWorker-8] C:\Python3\lib\site-packages\celery\backends\amqp.py:67: CPendingDeprecationWarning:
    The AMQP result backend is scheduled for deprecation in     version 4.0 and removal in version v5.0.
Please use RPC backend or a persistent backend.

alternative='Please use RPC backend or a persistent backend.')
[2018-1-28 08:19:42,792: INFO/MainProcess] mingle: all alone
[2018-1-28 08:19:42,802: INFO/MainProcess] celery@sh-int24 ready.
[2018-1-28 20:00:12,625: INFO/MainProcess] Received task: tasks.gen_prime[d293687a-c032-47e4-b9b2-4097a448d5e7]
[2018-1-28 20:00:12,688: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)',)
Traceback (most recent call last):
File "C:\Python3\lib\site-packages\billiard\pool.py", line 358, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
File "C:\Python3\lib\site-packages\celery\app\trace.py", line 537, in _fast_trace_task
    tasks, accept, hostname = _loc
ValueError: not enough values to unpack (expected 3, got 0)

And the command I issue: celery -A tasks worker

I use Windows 10 and python 3.6 anaconda distribution.

Gmosy Gnaq
  • 597
  • 1
  • 5
  • 18

1 Answers1

2

As described in this pull request you'll need

import os
os.environ.setdefault('FORKED_BY_MULTIPROCESSING', '1')

before 'app = Celery..."

Ochmar
  • 294
  • 2
  • 11