Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in the doc doesn't work on celery 4.0 #3580

Closed
bluedazzle opened this issue Nov 11, 2016 · 5 comments
Closed

Example in the doc doesn't work on celery 4.0 #3580

bluedazzle opened this issue Nov 11, 2016 · 5 comments

Comments

@bluedazzle
Copy link

Checklist

enviroment:
Mac OS X 10.11.4
celery==4.0
redis==3.0

Steps to reproduce

example from the docs http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html

from celery import Celery

app = Celery('tasks', backend='redis', broker='redis://localhost:6379/0')
app.conf.CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'

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

Expected behavior

Actual behavior

celery@MacBook-Pro.local v4.0.0 (latentcall)

Darwin-15.4.0-x86_64-i386-64bit 2016-11-11 15:36:53

[config]
.> app:         tasks:0x10270d4d0
.> transport:   redis://localhost:6379/0
.> results:     redis://localhost:6379/0
.> concurrency: 8 (prefork)
.> task events: OFF (enable -E to monitor tasks in this worker)

[queues]
.> celery           exchange=celery(direct) key=celery


[tasks]
  . task.add

[2016-11-11 15:36:53,365: INFO/MainProcess] Connected to redis://localhost:6379/0
[2016-11-11 15:36:53,375: INFO/MainProcess] mingle: searching for neighbors
[2016-11-11 15:36:54,392: INFO/MainProcess] mingle: all alone
[2016-11-11 15:36:54,405: INFO/MainProcess] celery@MacBook-Pro.local ready.
[2016-11-11 15:36:54,407: CRITICAL/MainProcess] Unrecoverable error: TypeError("can_read() got an unexpected keyword argument 'timeout'",)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/celery/worker/worker.py", line 203, in start
    self.blueprint.start(self)
  File "/usr/local/lib/python2.7/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/site-packages/celery/bootsteps.py", line 370, in start
    return self.obj.start()
  File "/usr/local/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 318, in start
    blueprint.start(self)
  File "/usr/local/lib/python2.7/site-packages/celery/bootsteps.py", line 119, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 584, in start
    c.loop(*c.loop_args())
  File "/usr/local/lib/python2.7/site-packages/celery/worker/loops.py", line 88, in asynloop
    next(loop)
  File "/usr/local/lib/python2.7/site-packages/kombu/async/hub.py", line 345, in create_loop
    cb(*cbargs)
  File "/usr/local/lib/python2.7/site-packages/kombu/transport/redis.py", line 1038, in on_readable
    self.cycle.on_readable(fileno)
  File "/usr/local/lib/python2.7/site-packages/kombu/transport/redis.py", line 337, in on_readable
    chan.handlers[type]()
  File "/usr/local/lib/python2.7/site-packages/kombu/transport/redis.py", line 670, in _receive
    while c.connection.can_read(timeout=0):
TypeError: can_read() got an unexpected keyword argument 'timeout'

PS: celery 3.1 doesn't have the issue above.it works well

@mcsalgado
Copy link

I believe this is somewhat related to #3586, when you try to inspect active tasks before the TypeError you get:

kombu.exceptions.EncodeError: b'[[4, 4], {}, {"chain": null, "errbacks": null, "chord": null, "callbacks": null}]' is not JSON serializable

@sww
Copy link
Contributor

sww commented Nov 30, 2016

@bluedazzle are you using the https://github.com/andymccurdy/redis-py redis library? If so, upgrading to >= 2.10.4 fixed the problem for me.

@bluedazzle
Copy link
Author

@sww Thanks a lot! it works!

@bluedazzle
Copy link
Author

@mcsalgado Thanks,upgrade python redis library will solve the problem,just as @sww said.

@GoodPaper
Copy link

@sww Thank you for saving time.

I add additional information about my failure case.

Environment

CentOS Linux release 7.2.1511 (Core)
python 3.4
redis 4.0.1
celery==4.0.0
redis==2.10.5

Case

  1. "A" Worker get lots of task. (Transferred long time tasks.)
  2. Inspect that "A" worker.
  3. "A" Worker is dead(or terminated??) with log below.
File "/usr/lib/python3.4/site-packages/kombu/transport/redis.py", line 670, in _receive
    while c.connection.can_read(timeout=0):
AttributeError: 'NoneType' object has no attribute 'can_read'

Troubleshooting

  1. I tried to update redis-py to 2.10.6 -> Doesn't work... Same error was occurred.
  2. I tried to update celery to 4.1.0 -> It works. There is no error in inspecting workers.

Solution

So... celery==4.1.0 and redis==2.10.6 combination is worked fine to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants