celery 与redis设置可见性\u超时不工作

cyej8jka  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(307)

我在用celery 配redis。可见性超时设置为10,以确保未确认的任务可以在10秒后重新交付,但重新交付的任务并不像我所想的那样出现。
tasks.py中的代码:

from celery import Celery

app = Celery('tasks', broker='redis://localhost:6379/0')
app.conf.broker_transport_options = {'visibility_timeout': 10}

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

我称之为任务的方式:

>>> from tasks import add
>>> add.apply_async(args=(2, 3), countdown=100)
<AsyncResult: 85925065-e7ed-4bee-ba8d-b64b4c9668f3>
>>>

我想 add 可以重新交付10次,但实际上只有一次。
celery 的调试日志:

[2020-05-24 14:50:44,345: DEBUG/MainProcess] basic.qos: prefetch_count->48
[2020-05-24 14:51:00,971: INFO/MainProcess] Received task: tasks.add[85925065-e7ed-4bee-ba8d-b64b4c9668f3]  ETA:[2020-05-24 06:52:40.745863+00:00]
[2020-05-24 14:51:00,972: DEBUG/MainProcess] basic.qos: prefetch_count->49
[2020-05-24 14:52:13,334: INFO/MainProcess] Received task: tasks.add[85925065-e7ed-4bee-ba8d-b64b4c9668f3]  ETA:[2020-05-24 06:52:40.745863+00:00]
[2020-05-24 14:52:13,334: DEBUG/MainProcess] basic.qos: prefetch_count->50
[2020-05-24 14:52:40,752: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x108bf84c0> (args:('tasks.add', '85925065-e7ed-4bee-ba8d-b64b4c9668f3', {'lang': 'py', 'task': 'tasks.add', 'id': '85925065-e7ed-4bee-ba8d-b64b4c9668f3', 'shadow': None, 'eta': '2020-05-24T06:52:40.745863+00:00', 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, None], 'root_id': '85925065-e7ed-4bee-ba8d-b64b4c9668f3', 'parent_id': None, 'argsrepr': '(2, 3)', 'kwargsrepr': '{}', 'origin': 'gen27761@', 'redelivered': True, 'reply_to': '93aa328c-f258-325f-bbb2-6750dccba39e', 'correlation_id': '85925065-e7ed-4bee-ba8d-b64b4c9668f3', 'hostname': 'celery@', 'delivery_info': {'exchange': '', 'routing_key': 'celery', 'priority': 0, 'redelivered': None}, 'args': [2, 3], 'kwargs': {}}, b'[[2, 3], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]', 'application/json', 'utf-8') kwargs:{})
[2020-05-24 14:52:40,753: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x108bf84c0> (args:('tasks.add', '85925065-e7ed-4bee-ba8d-b64b4c9668f3', {'lang': 'py', 'task': 'tasks.add', 'id': '85925065-e7ed-4bee-ba8d-b64b4c9668f3', 'shadow': None, 'eta': '2020-05-24T06:52:40.745863+00:00', 'expires': None, 'group': None, 'retries': 0, 'timelimit': [None, None], 'root_id': '85925065-e7ed-4bee-ba8d-b64b4c9668f3', 'parent_id': None, 'argsrepr': '(2, 3)', 'kwargsrepr': '{}', 'origin': 'gen27761@', 'reply_to': '93aa328c-f258-325f-bbb2-6750dccba39e', 'correlation_id': '85925065-e7ed-4bee-ba8d-b64b4c9668f3', 'hostname': 'celery@', 'delivery_info': {'exchange': '', 'routing_key': 'celery', 'priority': 0, 'redelivered': None}, 'args': [2, 3], 'kwargs': {}}, b'[[2, 3], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]', 'application/json', 'utf-8') kwargs:{})
[2020-05-24 14:52:41,611: DEBUG/MainProcess] basic.qos: prefetch_count->48
[2020-05-24 14:52:41,614: DEBUG/MainProcess] Task accepted: tasks.add[85925065-e7ed-4bee-ba8d-b64b4c9668f3] pid:27731
[2020-05-24 14:52:41,615: DEBUG/MainProcess] Task accepted: tasks.add[85925065-e7ed-4bee-ba8d-b64b4c9668f3] pid:27738
[2020-05-24 14:52:41,615: INFO/ForkPoolWorker-1] Task tasks.add[85925065-e7ed-4bee-ba8d-b64b4c9668f3] succeeded in 0.0004569360000061806s: 5
[2020-05-24 14:52:41,615: INFO/ForkPoolWorker-8] Task tasks.add[85925065-e7ed-4bee-ba8d-b64b4c9668f3] succeeded in 0.0005230149999988498s: 5

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题