首页 > 解决方案 > django-q 任务队列:失败的任务会一直处理下去

问题描述

任何使用 django-q 任务调度程序的人:https ://github.com/Koed00/django-q ?

(不是数据库相关Q库)

我有一堆失败的任务。每次我运行 django-q 时,这些失败的任务都会不断弹出:

18:06:14 [Q] INFO Process-1:9 processing [apart-sixteen-butter-friend]
18:06:14 [Q] INFO Process-1:10 processing [single-mississippi-bravo-fillet]
18:06:14 [Q] ERROR Failed [lithium-cola-batman-fanta] - No module named 'shootsta.user'
18:06:14 [Q] INFO Process-1:9 processing [ink-october-angel-california]
18:06:14 [Q] ERROR Failed [zulu-michigan-yankee-kilo] - No module named 'shootsta.user'
18:06:14 [Q] ERROR Failed [four-lemon-arizona-football] - No module named 'shootsta.user'
18:06:14 [Q] ERROR Failed [mississippi-fillet-winner-single] - No module named 'shootsta.user'
18:06:14 [Q] ERROR Failed [west-pennsylvania-asparagus-alabama] - 'BookingAnalytics' object has no attribute 'booking_uid'
18:06:14 [Q] ERROR Failed [wisconsin-pip-alanine-seventeen] - Can't switch from state 'job_complete' using method 'assign_camop'
18:06:14 [Q] ERROR Failed [finch-monkey-moon-oven] - 'AnalyticsFilter' object is not iterable
18:06:14 [Q] ERROR Failed [yellow-west-mango-papa] - 'AnalyticsFilter' object is not iterable
18:06:14 [Q] ERROR Failed [zulu-equal-mississippi-happy] - 'str' object has no attribute 'booking_uid'
18:06:14 [Q] ERROR Failed [six-beer-golf-blue] - 'str' object has no attribute 'booking_uid'
18:06:14 [Q] ERROR Failed [apart-sixteen-butter-friend] - 'str' object has no attribute 'booking_uid'
18:06:14 [Q] ERROR Failed [single-mississippi-bravo-fillet] - 'str' object has no attribute 'booking_uid'
18:06:14 [Q] ERROR Failed [ink-october-angel-california] - 'str' object has no attribute 'booking_uid'
18:06:15 [Q] ERROR reincarnated worker Process-1:4 after death
18:06:15 [Q] INFO Process-1:11 ready for work at 20244

这些失败任务中提到的相关问题已得到修复。然而,失败的任务不断出现。即使我从数据库(django_q_task表)中删除失败的条目,每次运行qcluster命令时都会重新创建它们。

如何处理此问题并阻止这些错误出现在输出中?

标签: pythondjango

解决方案


它是新添加的配置:您可以根据此拉取请求attempt_count设置为 1 。

max_attempts不够好且令人困惑 -因为最小重试次数为 1 - 所以失败任务的总调用次数为 2。

'ack_failures': True请记住,如果引发 an ,您还需要设置Exception- 以确认失败。

令人困惑但可行的是:

Q_CLUSTER = {
    'name': 'DjangORM',
    'workers': 1,
    'timeout': 600,
    'orm': 'default',
    'save_limit': 0,
    'ack_failures': True,
    'max_attempts': 1,
    'attempt_count': 1
}

推荐阅读