Celery with redis - unix timeout

I have an application that uses celery for an async task, and I use redis for my brokerage and final backend, and I decided to use redis to use a unix socket. here is my url for celery and broker

brok = 'redis+socket://:ABc@/tmp/redis.sock'
app = Celery('NTWBT', backend=brok, broker=brok)
app.conf.update(
    BROKER_URL=brok,
    BROKER_TRANSPORT_OPTIONS={
        "visibility_timeout": 3600
    },
    CELERY_RESULT_BACKEND=brok,
    CELERY_ACCEPT_CONTENT=['pickle', 'json', 'msgpack', 'yaml'],
)

but every time I add work celery gives me this error

Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 283, in trace_task
    uuid, retval, SUCCESS, request=task_request,
  File "/usr/local/lib/python2.7/dist-packages/celery/backends/base.py", line 257, in store_result
    request=request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/backends/base.py", line 491, in _store_result
    self.set(self.get_key_for_task(task_id), self.encode(meta))
  File "/usr/local/lib/python2.7/dist-packages/celery/backends/redis.py", line 160, in set
    return self.ensure(self._set, (key, value), **retry_policy)
  File "/usr/local/lib/python2.7/dist-packages/celery/backends/redis.py", line 149, in ensure
    **retry_policy
  File "/usr/local/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 246, in retry_over_time
    return fun(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/celery/backends/redis.py", line 169, in _set
    pipe.execute()
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2620, in execute
    self.shard_hint)
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 897, in get_connection
    connection = self.make_connection()
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 906, in make_connection
    return self.connection_class(**self.connection_kwargs)
TypeError: __init__() got an unexpected keyword argument 'socket_connect_timeout'

Which option should I use for celery to set the timeout for dialing it again?

+4
source share
2 answers

it looks like this problem is related to the version of redis server installed on your system, socket_connect_timeout was first introduced in redis 2.10.0.

so you need to update the redis version.

ubuntu, apt:

$ sudo apt-get install -y python-software-properties
$ sudo add-apt-repository -y ppa:rwky/redis
$ sudo apt-get update
$ sudo apt-get install -y redis-server

.

github , : https://github.com/celery/celery/issues/2903

, rabbitmq Redis:

$ sudo apt-get install rabbitmq-server
$ sudo pip install librabbitmq

CELERY_BROKER_URL:

'amqp://guest:guest@localhost:5672//'

, .

0

, Celery:

Redis UNIX- , . monkey-patch celery, kombu / redis-py...

Redis TCP- , . RabbitMQ.

0

Source: https://habr.com/ru/post/1620292/


All Articles