p1-taskqueue 0.1.14__py3-none-any.whl → 0.1.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of p1-taskqueue might be problematic. Click here for more details.
- {p1_taskqueue-0.1.14.dist-info → p1_taskqueue-0.1.16.dist-info}/METADATA +1 -1
- {p1_taskqueue-0.1.14.dist-info → p1_taskqueue-0.1.16.dist-info}/RECORD +5 -5
- taskqueue/celery_app.py +41 -9
- {p1_taskqueue-0.1.14.dist-info → p1_taskqueue-0.1.16.dist-info}/WHEEL +0 -0
- {p1_taskqueue-0.1.14.dist-info → p1_taskqueue-0.1.16.dist-info}/top_level.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
taskqueue/__init__.py,sha256=nNHXIyysNLom9f8of-d__pWJ-YF53Mbrbsb1frPzPPI,298
|
|
2
|
-
taskqueue/celery_app.py,sha256=
|
|
2
|
+
taskqueue/celery_app.py,sha256=0FaotFOUCKkJf8YQ2RySmRMBBIhh_ZoFXFJVrxZad5w,5263
|
|
3
3
|
taskqueue/cmanager.py,sha256=9jxcTsWOpzexV3SkRhlY-PkhrobEdMuQVm6tWVVzgTs,16260
|
|
4
4
|
taskqueue/slack_notifier.py,sha256=ZvTbWa1XXHUiciYF14_SH5af0BvGoPCBQohPtxx4FgU,1419
|
|
5
5
|
taskqueue/libs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
taskqueue/libs/helper_test.py,sha256=3f7RoYEDBIpLHG1YY3eQ_RqZvkm4Er3FDEvFJeoAc8o,9572
|
|
7
|
-
p1_taskqueue-0.1.
|
|
8
|
-
p1_taskqueue-0.1.
|
|
9
|
-
p1_taskqueue-0.1.
|
|
10
|
-
p1_taskqueue-0.1.
|
|
7
|
+
p1_taskqueue-0.1.16.dist-info/METADATA,sha256=NyP1LDXMON9P_hYIK1jPvHH9s8YMxXvWP9ah8pFZ3_k,1597
|
|
8
|
+
p1_taskqueue-0.1.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
p1_taskqueue-0.1.16.dist-info/top_level.txt,sha256=hA3SM1ik2K8iPqtlt_-_nJ4TAePwHPN3vsOc4EiynqU,10
|
|
10
|
+
p1_taskqueue-0.1.16.dist-info/RECORD,,
|
taskqueue/celery_app.py
CHANGED
|
@@ -4,6 +4,7 @@ Reads configuration from Django settings and auto-configures queues with DLQ.
|
|
|
4
4
|
"""
|
|
5
5
|
import logging
|
|
6
6
|
|
|
7
|
+
from amqp.exceptions import PreconditionFailed
|
|
7
8
|
from celery import Celery
|
|
8
9
|
from kombu import Exchange
|
|
9
10
|
from kombu import Queue
|
|
@@ -52,7 +53,7 @@ def create_celery_app():
|
|
|
52
53
|
'worker_max_tasks_per_child': 1000,
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
setup_queues(app, settings, celery_config)
|
|
56
|
+
# setup_queues(app, settings, celery_config)
|
|
56
57
|
app.conf.update(celery_config)
|
|
57
58
|
app.autodiscover_tasks(['taskqueue'])
|
|
58
59
|
|
|
@@ -67,6 +68,9 @@ def setup_queues(app, settings, celery_config):
|
|
|
67
68
|
queue_names = ['default', 'high', 'low']
|
|
68
69
|
dlq_name_prefix = getattr(settings, 'TASKQUEUE_DLQ_NAME_PREFIX', 'dlq')
|
|
69
70
|
|
|
71
|
+
logger.info(
|
|
72
|
+
f"[TaskQueue] Configuring app: {app_name}, queues: {queue_names}")
|
|
73
|
+
|
|
70
74
|
main_exchange = Exchange(app_name, type='direct')
|
|
71
75
|
dlx_exchange = Exchange(f'{app_name}.dlx', type='direct')
|
|
72
76
|
|
|
@@ -74,22 +78,28 @@ def setup_queues(app, settings, celery_config):
|
|
|
74
78
|
|
|
75
79
|
for queue_name in queue_names:
|
|
76
80
|
dlq_name = f'{dlq_name_prefix}.{queue_name}'
|
|
81
|
+
dlx_name = f'{app_name}.dlx'
|
|
82
|
+
|
|
83
|
+
queue_args = {
|
|
84
|
+
'x-dead-letter-exchange': dlx_name,
|
|
85
|
+
'x-dead-letter-routing-key': dlq_name
|
|
86
|
+
}
|
|
77
87
|
|
|
78
88
|
queue = Queue(
|
|
79
89
|
queue_name,
|
|
80
90
|
main_exchange,
|
|
81
91
|
routing_key=queue_name,
|
|
82
|
-
queue_arguments=
|
|
83
|
-
'x-dead-letter-exchange': f'{app_name}.dlx',
|
|
84
|
-
'x-dead-letter-routing-key': dlq_name
|
|
85
|
-
}
|
|
92
|
+
queue_arguments=queue_args
|
|
86
93
|
)
|
|
87
94
|
queues.append(queue)
|
|
95
|
+
logger.info(
|
|
96
|
+
f"[TaskQueue] Queue '{queue_name}' configured with DLX: {dlx_name}, DLQ routing key: {dlq_name}")
|
|
88
97
|
|
|
89
98
|
for queue_name in queue_names:
|
|
90
99
|
dlq_name = f'{dlq_name_prefix}.{queue_name}'
|
|
91
100
|
dlq = Queue(dlq_name, dlx_exchange, routing_key=dlq_name)
|
|
92
101
|
queues.append(dlq)
|
|
102
|
+
logger.info(f"[TaskQueue] DLQ '{dlq_name}' configured")
|
|
93
103
|
|
|
94
104
|
celery_config.update({
|
|
95
105
|
'task_default_queue': 'default',
|
|
@@ -100,14 +110,36 @@ def setup_queues(app, settings, celery_config):
|
|
|
100
110
|
|
|
101
111
|
try:
|
|
102
112
|
with app.connection_or_acquire() as conn:
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
channel = conn.default_channel
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
main_exchange.declare(channel=channel)
|
|
117
|
+
logger.info(f"[TaskQueue] Exchange declared: {app_name}")
|
|
118
|
+
except PreconditionFailed:
|
|
119
|
+
logger.info(f"[TaskQueue] Exchange already exists: {app_name}")
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
dlx_exchange.declare(channel=channel)
|
|
123
|
+
logger.info(
|
|
124
|
+
f"[TaskQueue] DLX Exchange declared: {app_name}.dlx")
|
|
125
|
+
except PreconditionFailed:
|
|
126
|
+
logger.info(
|
|
127
|
+
f"[TaskQueue] DLX Exchange already exists: {app_name}.dlx")
|
|
105
128
|
|
|
106
129
|
for queue in queues:
|
|
107
|
-
|
|
130
|
+
try:
|
|
131
|
+
queue.declare(channel=channel)
|
|
132
|
+
logger.info(f"[TaskQueue] Queue declared: {queue.name}")
|
|
133
|
+
except PreconditionFailed:
|
|
134
|
+
logger.info(
|
|
135
|
+
f"[TaskQueue] Queue already exists with different config: {queue.name}. Using existing queue.")
|
|
136
|
+
except Exception as e:
|
|
137
|
+
logger.warning(
|
|
138
|
+
f"[TaskQueue] Failed to declare queue {queue.name}: {e}")
|
|
139
|
+
|
|
108
140
|
except Exception as e:
|
|
109
141
|
logger.warning(
|
|
110
|
-
f"[TaskQueue] Failed to
|
|
142
|
+
f"[TaskQueue] Failed to setup queues: {str(e.__class__.__name__)} {e}")
|
|
111
143
|
|
|
112
144
|
|
|
113
145
|
celery_app = create_celery_app()
|
|
File without changes
|
|
File without changes
|