django-qstash 0.0.15__py3-none-any.whl → 0.1.1__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 django-qstash might be problematic. Click here for more details.
- django_qstash/__init__.py +1 -1
- django_qstash/results/services.py +25 -8
- {django_qstash-0.0.15.dist-info → django_qstash-0.1.1.dist-info}/METADATA +5 -5
- {django_qstash-0.0.15.dist-info → django_qstash-0.1.1.dist-info}/RECORD +6 -6
- {django_qstash-0.0.15.dist-info → django_qstash-0.1.1.dist-info}/WHEEL +0 -0
- {django_qstash-0.0.15.dist-info → django_qstash-0.1.1.dist-info}/top_level.txt +0 -0
django_qstash/__init__.py
CHANGED
|
@@ -12,14 +12,31 @@ from django_qstash.db.models import TaskStatus
|
|
|
12
12
|
logger = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
def function_result_to_dict(result: Any) -> dict | None:
|
|
16
|
+
"""
|
|
17
|
+
Convert a task result to a Python dict for the result JSONField.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
result: Any Python value to be converted
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
dict: A dictionary representation of the result
|
|
24
|
+
None: If the input is None
|
|
25
|
+
"""
|
|
26
|
+
if result is None:
|
|
22
27
|
return None
|
|
28
|
+
elif isinstance(result, dict):
|
|
29
|
+
return result
|
|
30
|
+
elif isinstance(result, str):
|
|
31
|
+
try:
|
|
32
|
+
parsed = json.loads(result)
|
|
33
|
+
if isinstance(parsed, dict):
|
|
34
|
+
return parsed
|
|
35
|
+
return {"result": parsed}
|
|
36
|
+
except json.JSONDecodeError as e:
|
|
37
|
+
logger.info("Task result is not a JSON string: %s", str(e))
|
|
38
|
+
return {"result": result}
|
|
39
|
+
return {"result": result}
|
|
23
40
|
|
|
24
41
|
|
|
25
42
|
def store_task_result(
|
|
@@ -44,7 +61,7 @@ def store_task_result(
|
|
|
44
61
|
task_name=task_name,
|
|
45
62
|
status=status,
|
|
46
63
|
date_done=timezone.now(),
|
|
47
|
-
result=
|
|
64
|
+
result=function_result_to_dict(result),
|
|
48
65
|
traceback=traceback,
|
|
49
66
|
args=args,
|
|
50
67
|
kwargs=kwargs,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: django-qstash
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: A drop-in replacement for Celery's shared_task with Upstash QStash.
|
|
5
5
|
Author-email: Justin Mitchel <justin@codingforentrepreneurs.com>
|
|
6
6
|
Project-URL: Changelog, https://github.com/jmitchel3/django-qstash
|
|
@@ -27,11 +27,11 @@ Requires-Dist: django>=4.2
|
|
|
27
27
|
Requires-Dist: qstash>=2
|
|
28
28
|
Requires-Dist: requests>=2.30
|
|
29
29
|
|
|
30
|
-
> :warning: **BETA Software**: Working on being production-ready soon.
|
|
31
|
-
|
|
32
30
|
# django-qstash
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
Run background tasks with Django through webhooks and Upstash QStash.
|
|
33
|
+
|
|
34
|
+
_django-qstash_ is designed to be a drop-in replacement for Celery's `shared_task` or run alongside Celery.
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
## How it works
|
|
@@ -46,7 +46,7 @@ from django_qstash import shared_task
|
|
|
46
46
|
def my_task():
|
|
47
47
|
pass
|
|
48
48
|
```
|
|
49
|
-
> To use Celery
|
|
49
|
+
> To use django-qstash with Celery, you can use `@stashed_task` instead of `@shared_task` (more below).
|
|
50
50
|
|
|
51
51
|
To do this we need:
|
|
52
52
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
django_qstash/__init__.py,sha256=
|
|
1
|
+
django_qstash/__init__.py,sha256=I0hIqZOy7-YAHc5SHRlQxXlnOQf5rwI0GkiJBmyvSas,187
|
|
2
2
|
django_qstash/callbacks.py,sha256=IQ-D8sPlSRuREZ1zwkRyd2GtxfmrJJh2x4jLd39rZCE,813
|
|
3
3
|
django_qstash/client.py,sha256=9xO4iwR62PkEQhzC92yKRlzqEIF5Yi0HpYc88v_drsI,612
|
|
4
4
|
django_qstash/cron.py,sha256=13OzTMGXFgjNEXjs2Et20WGZYtW9lKlu79BjbRySnVc,716
|
|
@@ -27,7 +27,7 @@ django_qstash/results/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
|
27
27
|
django_qstash/results/admin.py,sha256=Vr1O6E7vucSnkZ1PwHQ7RYkwOxiX4WHPAKaA7L8Cn-4,580
|
|
28
28
|
django_qstash/results/apps.py,sha256=4me4cg5yeoeSJTphkHYzGMJUfGucT47FNIUMYu5gmIo,275
|
|
29
29
|
django_qstash/results/models.py,sha256=AV7-nVEMq-Xt2QVY6D7NQc4_3E7v-6NA2xngTU8DfXA,1062
|
|
30
|
-
django_qstash/results/services.py,sha256=
|
|
30
|
+
django_qstash/results/services.py,sha256=150IP9A_93bm6wZQjRqAmMyBvyigSlUXTca14DpqAxQ,2069
|
|
31
31
|
django_qstash/results/tasks.py,sha256=kd49OOZyOg6OG3RSyywtZPtpGaPlycY2OXl1BXaoxVM,2746
|
|
32
32
|
django_qstash/results/migrations/0001_initial.py,sha256=A90SKgWmBf4SIJYG1Jh6-b_81Ia1zIzGj3Bfl1O4-kg,1902
|
|
33
33
|
django_qstash/results/migrations/0002_taskresult_function_path_alter_taskresult_status_and_more.py,sha256=FevtPlzkKHjRD1tcnXskigY5jr2X3gYv7KE2TcdEAxU,1374
|
|
@@ -46,7 +46,7 @@ django_qstash/schedules/migrations/0001_initial.py,sha256=66cA8xnJV3h7QgzCaOiv-N
|
|
|
46
46
|
django_qstash/schedules/migrations/0002_taskschedule_updated_at.py,sha256=6hZO0a9P2ZpOROkk7O5UXBhahghU0QfxZl4E-c3HKGw,459
|
|
47
47
|
django_qstash/schedules/migrations/0003_alter_taskschedule_cron.py,sha256=oBW_FcvosKsa0l_l3eVDRIZli5K1wQaN_DJjamVe23s,826
|
|
48
48
|
django_qstash/schedules/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
|
-
django_qstash-0.
|
|
50
|
-
django_qstash-0.
|
|
51
|
-
django_qstash-0.
|
|
52
|
-
django_qstash-0.
|
|
49
|
+
django_qstash-0.1.1.dist-info/METADATA,sha256=2CrKOZTyZRapVWDBHFW9-mrxON_VOmzZQuEZDHaywz4,21263
|
|
50
|
+
django_qstash-0.1.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
51
|
+
django_qstash-0.1.1.dist-info/top_level.txt,sha256=AlV3WSK1A0ZvKuCLsINtIJhJW8zo7SEB-D3_RAjZ0hI,14
|
|
52
|
+
django_qstash-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|