p1-taskqueue 0.1.13__py3-none-any.whl → 0.1.15__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.13.dist-info → p1_taskqueue-0.1.15.dist-info}/METADATA +1 -1
- p1_taskqueue-0.1.15.dist-info/RECORD +10 -0
- taskqueue/celery_app.py +40 -8
- taskqueue/libs/helper_test.py +26 -0
- p1_taskqueue-0.1.13.dist-info/RECORD +0 -10
- {p1_taskqueue-0.1.13.dist-info → p1_taskqueue-0.1.15.dist-info}/WHEEL +0 -0
- {p1_taskqueue-0.1.13.dist-info → p1_taskqueue-0.1.15.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
taskqueue/__init__.py,sha256=nNHXIyysNLom9f8of-d__pWJ-YF53Mbrbsb1frPzPPI,298
|
|
2
|
+
taskqueue/celery_app.py,sha256=BR1wHezSOFanFwSCINnrWvjoiZTNy0o0nUe4o8RYCsI,5261
|
|
3
|
+
taskqueue/cmanager.py,sha256=9jxcTsWOpzexV3SkRhlY-PkhrobEdMuQVm6tWVVzgTs,16260
|
|
4
|
+
taskqueue/slack_notifier.py,sha256=ZvTbWa1XXHUiciYF14_SH5af0BvGoPCBQohPtxx4FgU,1419
|
|
5
|
+
taskqueue/libs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
taskqueue/libs/helper_test.py,sha256=3f7RoYEDBIpLHG1YY3eQ_RqZvkm4Er3FDEvFJeoAc8o,9572
|
|
7
|
+
p1_taskqueue-0.1.15.dist-info/METADATA,sha256=4qt4wqWTT0dXDFwgdgAodk6I51Z_XXEwvZI47JCSLDs,1597
|
|
8
|
+
p1_taskqueue-0.1.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
p1_taskqueue-0.1.15.dist-info/top_level.txt,sha256=hA3SM1ik2K8iPqtlt_-_nJ4TAePwHPN3vsOc4EiynqU,10
|
|
10
|
+
p1_taskqueue-0.1.15.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
|
|
@@ -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()
|
taskqueue/libs/helper_test.py
CHANGED
|
@@ -70,6 +70,19 @@ def celery_worker_burst(include_func_names: List[str], channel: str = "default")
|
|
|
70
70
|
method_name = task_kwargs.get('method_name', '')
|
|
71
71
|
if module_path and class_name and method_name:
|
|
72
72
|
full_func_name = f"{module_path}.{class_name}.{method_name}"
|
|
73
|
+
elif task_name.endswith("callable_executor"):
|
|
74
|
+
callable_obj = task_kwargs.get('callable_obj')
|
|
75
|
+
if callable_obj:
|
|
76
|
+
module_path = getattr(
|
|
77
|
+
callable_obj, '__module__', '')
|
|
78
|
+
func_name = getattr(
|
|
79
|
+
callable_obj, '__name__', '')
|
|
80
|
+
if hasattr(callable_obj, '__self__'):
|
|
81
|
+
class_name = callable_obj.__self__.__class__.__name__
|
|
82
|
+
if module_path and class_name and func_name:
|
|
83
|
+
full_func_name = f"{module_path}.{class_name}.{func_name}"
|
|
84
|
+
elif module_path and func_name:
|
|
85
|
+
full_func_name = f"{module_path}.{func_name}"
|
|
73
86
|
|
|
74
87
|
should_execute = full_func_name in included_set if full_func_name else False
|
|
75
88
|
|
|
@@ -136,6 +149,19 @@ def get_queued_tasks(channel: str = "default"):
|
|
|
136
149
|
method_name = task_kwargs.get('method_name', '')
|
|
137
150
|
if module_path and class_name and method_name:
|
|
138
151
|
full_func_name = f"{module_path}.{class_name}.{method_name}"
|
|
152
|
+
elif task_name and task_name.endswith("callable_executor"):
|
|
153
|
+
callable_obj = task_kwargs.get('callable_obj')
|
|
154
|
+
if callable_obj:
|
|
155
|
+
module_path = getattr(
|
|
156
|
+
callable_obj, '__module__', '')
|
|
157
|
+
func_name = getattr(
|
|
158
|
+
callable_obj, '__name__', '')
|
|
159
|
+
if hasattr(callable_obj, '__self__'):
|
|
160
|
+
class_name = callable_obj.__self__.__class__.__name__
|
|
161
|
+
if module_path and class_name and func_name:
|
|
162
|
+
full_func_name = f"{module_path}.{class_name}.{func_name}"
|
|
163
|
+
elif module_path and func_name:
|
|
164
|
+
full_func_name = f"{module_path}.{func_name}"
|
|
139
165
|
|
|
140
166
|
queued_tasks.append({
|
|
141
167
|
'task_name': task_name,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
taskqueue/__init__.py,sha256=nNHXIyysNLom9f8of-d__pWJ-YF53Mbrbsb1frPzPPI,298
|
|
2
|
-
taskqueue/celery_app.py,sha256=rLIYRBBgYaQiXEqz-zCntvS8xU4eFZ9YuhJBfIye9E0,3931
|
|
3
|
-
taskqueue/cmanager.py,sha256=9jxcTsWOpzexV3SkRhlY-PkhrobEdMuQVm6tWVVzgTs,16260
|
|
4
|
-
taskqueue/slack_notifier.py,sha256=ZvTbWa1XXHUiciYF14_SH5af0BvGoPCBQohPtxx4FgU,1419
|
|
5
|
-
taskqueue/libs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
taskqueue/libs/helper_test.py,sha256=JCdh2S29PpL8RqUxqkcIqwIvr3M9puqHglBZAmfPkuw,7722
|
|
7
|
-
p1_taskqueue-0.1.13.dist-info/METADATA,sha256=pr73Jir2XbTBsq2HieYSEO4h0a_FM5KV15THqfedOM0,1597
|
|
8
|
-
p1_taskqueue-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
p1_taskqueue-0.1.13.dist-info/top_level.txt,sha256=hA3SM1ik2K8iPqtlt_-_nJ4TAePwHPN3vsOc4EiynqU,10
|
|
10
|
-
p1_taskqueue-0.1.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|