Kombu 4.1 seems to break celery's task_publish_retry
See original GitHub issueDear valued Kombu developers,
when using Celery with RabbitMQ I stumbled across a problem where celery’s task_publish_retry gets not honored, when I use Kombu 4.1.0. Please see below my Bug report. If you have any further questions, please let me know.
Many thanks in advance. Best Regards, Stephan
Environment:
- Debian 8.9 with python 3.4.2
- amqp==2.2.1
- billiard==3.5.0.3
- celery==4.1.0
- kombu==4.1.0
- pytz==2017.2
- vine==1.1.4
Steps to reproduce:
- Make sure Broker is NOT running
- Create tasks.py
from celery import Celery
app = Celery('tasks', broker='pyamqp://celery:secret@localhost/myvhost')
@app.task
def add(x, y):
return x + y
- Create test.py
from tasks import add
add.apply_async((4,4), retry=False)
- Run test.py
- Expected result: kombu.exceptions.OperationalError raised because connection to broker cannot be established
- Observed result: test.py blocks/hangs.
- Hit CTRL-C to get the stack trace Traceback (most recent call last): File “/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/utils/functional.py”, line 36, in call return self.value AttributeError: ‘ChannelPromise’ object has no attribute ‘value’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/utils/functional.py", line 333, in retry_over_time
return fun(*args, **kwargs)
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/connection.py", line 261, in connect
return self.connection
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/connection.py", line 802, in connection
self._connection = self._establish_connection()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/connection.py", line 757, in _establish_connection
conn = self.transport.establish_connection()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/transport/pyamqp.py", line 130, in establish_connection
conn.connect()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/amqp/connection.py", line 296, in connect
self.transport.connect()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/amqp/transport.py", line 123, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/amqp/transport.py", line 164, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 2, in <module>
add.apply_async((4,4), retry=False)
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/celery/app/task.py", line 536, in apply_async
**options
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/celery/app/base.py", line 737, in send_task
amqp.send_task_message(P, name, message, **options)
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/celery/app/amqp.py", line 554, in send_task_message
**properties
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/messaging.py", line 181, in publish
exchange_name, declare,
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/messaging.py", line 187, in _publish
channel = self.channel
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/messaging.py", line 209, in _get_channel
channel = self._channel = channel()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/utils/functional.py", line 38, in __call__
value = self.__value__ = self.__contract__()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/messaging.py", line 224, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/connection.py", line 819, in default_channel
self.ensure_connection()
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/connection.py", line 405, in ensure_connection
callback)
File "/home/a2822bp/.virtualenvs/dssweb/lib/python3.4/site-packages/kombu/utils/functional.py", line 345, in retry_over_time
sleep(1.0)
KeyboardInterrupt
-
Install Kombu 4.0.2 using pip install --upgrade kombu==4.0.2
-
Rerun test.py
- Exception is raised as expected:
kombu.exceptions.OperationalError: [Errno 111] Connection refused
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Kombu Documentation - Celery
Kombu is a messaging library for Python. The aim of Kombu is to make messaging in Python as easy as possible by providing...
Read more >Two years with Celery in Production: Bug Fix Edition - Medium
Publishers did not adhere to “task publish retry policy”. Tl;dr: task_publish_retry_policy is broken in kombu==4.1.0 , we downgraded to 4.0.2 .
Read more >Automatically Retrying Failed Celery Tasks - TestDriven.io
Objectives · Retry a failed Celery task with both the retry method and a decorator argument · Use exponential backoff when retrying a...
Read more >Celery worker hangs without any error - Stack Overflow
0, kombu==4.1.0 whether they are supporting or not. Mentioned versions are just an example. And Also check whether redis is install in your ......
Read more >Celery task retry guide - Ines Panker
Celery never retries your tasks, unless you tell it to. Here is how you can tell her to:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This useless issue has not been fixed yet its a shame and annoying I am running django pytest with rabbitmq and celery. When I run the pytest without starting the server I get the same issue kombu.exceptions.OperationalError: [Errno 111] Connection refused
Need a fix
https://github.com/celery/kombu/pull/769 should fix it