p1-taskqueue 0.1.14__tar.gz → 0.1.15__tar.gz

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.

Files changed (20) hide show
  1. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/PKG-INFO +1 -1
  2. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/pyproject.toml +1 -1
  3. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/p1_taskqueue.egg-info/PKG-INFO +1 -1
  4. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/taskqueue/celery_app.py +40 -8
  5. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/README.md +0 -0
  6. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/setup.cfg +0 -0
  7. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/p1_taskqueue.egg-info/SOURCES.txt +0 -0
  8. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/p1_taskqueue.egg-info/dependency_links.txt +0 -0
  9. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/p1_taskqueue.egg-info/requires.txt +0 -0
  10. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/p1_taskqueue.egg-info/top_level.txt +0 -0
  11. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/taskqueue/__init__.py +0 -0
  12. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/taskqueue/cmanager.py +0 -0
  13. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/taskqueue/libs/__init__.py +0 -0
  14. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/taskqueue/libs/helper_test.py +0 -0
  15. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/src/taskqueue/slack_notifier.py +0 -0
  16. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/tests/test_celery_app.py +0 -0
  17. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/tests/test_cmanager.py +0 -0
  18. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/tests/test_helper_test_functions.py +0 -0
  19. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/tests/test_return_values.py +0 -0
  20. {p1_taskqueue-0.1.14 → p1_taskqueue-0.1.15}/tests/test_test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: p1-taskqueue
3
- Version: 0.1.14
3
+ Version: 0.1.15
4
4
  Summary: A Task Queue Wrapper for Dekoruma Backend
5
5
  Author-email: Chalvin <engineering@dekoruma.com>
6
6
  Project-URL: Homepage, https://github.com/Dekoruma/p1-taskqueue
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "p1-taskqueue"
7
7
  # DO NOT CHANGE THIS VERSION - it gets automatically replaced by CI/CD with the git tag version
8
- version = "0.1.14"
8
+ version = "0.1.15"
9
9
  description = "A Task Queue Wrapper for Dekoruma Backend"
10
10
  authors = [
11
11
  {name = "Chalvin", email = "engineering@dekoruma.com"}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: p1-taskqueue
3
- Version: 0.1.14
3
+ Version: 0.1.15
4
4
  Summary: A Task Queue Wrapper for Dekoruma Backend
5
5
  Author-email: Chalvin <engineering@dekoruma.com>
6
6
  Project-URL: Homepage, https://github.com/Dekoruma/p1-taskqueue
@@ -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
- main_exchange.declare(channel=conn.default_channel)
104
- dlx_exchange.declare(channel=conn.default_channel)
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
- queue.declare(channel=conn.default_channel)
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 declare queues: {str(e.__class__.__name__)} {e}")
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