Тёмный

Django + Celery: Create Your First Background Worker! 

Bennett Garner
Подписаться 4,7 тыс.
Просмотров 18 тыс.
50% 1

Опубликовано:

 

24 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 27   
@azizdridi2599
@azizdridi2599 7 месяцев назад
underrated tutorial, saved my day fr
@janirico5641
@janirico5641 3 года назад
thanks a lot, the code, video and documentation, very rare to get all 3, and thank you for a simple video on celery...
@BennettGarner
@BennettGarner 3 года назад
Glad it was helpful!
@aminulc
@aminulc Год назад
Good explanation. Thank you.
@BennettGarner
@BennettGarner Год назад
Glad you liked it
@fabriciosaavedra3795
@fabriciosaavedra3795 3 года назад
My man, you just made my day a whole better. I'm only slightly confused about the procedence of self.request in the debug_task, but might just be me. Great vid.
@BennettGarner
@BennettGarner 3 года назад
Glad I could help! When we ran `debug_task.delay()`, we placed a task in the Celery queue with all kinds of request information. That information got loaded into the worker as `self.request`. So, for our debug task we were simply printing the request. But for a real task, we would include some information in the request to help the worker know how to execute its job (e.g. the ID of a model in the database or raw arguments/data that we want to be transformed)
@fabriciosaavedra3795
@fabriciosaavedra3795 3 года назад
@@BennettGarner thanks for replying! What I don't quite get is if that request information you're giving to the worker would be the same request information that the view function is receiving.
@BennettGarner
@BennettGarner 3 года назад
@@fabriciosaavedra3795 In the example, there isn't a view function. Actually, if you look at the source code, there isn't even a `views.py`. Instead, the request information comes from the time and configuration when we executed `debug_task.delay()` in an interactive shell. While you could pass information from the view into your worker (and probably will want to), you'd do that using `debug_task.delay(task_information)`. Does that clarify things?
@pranjulsingh658
@pranjulsingh658 3 года назад
Thanks a lot. It would be very very helpful to see more celery with django tutorials. :D
@BennettGarner
@BennettGarner 3 года назад
Noted!
@SumitSontakke-nb6px
@SumitSontakke-nb6px Год назад
Thanks Bannett for this tutorial. I'm struggling to install celery on my Mac OS. It takes a lot time and never completes. Please help!
@BennettGarner
@BennettGarner Год назад
"pip install celery" is the command. If that takes a long time, it's likely you have slow internet?
@wanyoikedanny472
@wanyoikedanny472 3 года назад
how to daemonize it ro run as a background process in windows?
@BennettGarner
@BennettGarner 3 года назад
I'd use a tool like systemd. Info here: docs.celeryproject.org/en/stable/userguide/daemonizing.html
@wanyoikedanny472
@wanyoikedanny472 3 года назад
@@BennettGarner unfortunately this is not for windows😥😥
@BennettGarner
@BennettGarner 3 года назад
@@wanyoikedanny472 I'd suggest using Docker then to containerize it. Is there a reason your webserver/worker servers need to run on windows? It greatly complicates things and makes support difficult.
@pranjulsingh658
@pranjulsingh658 3 года назад
Could you please also make a tutorial video to set up tasks to fetch some data and save them in a database using celery in django. thanks in advance :)
@BennettGarner
@BennettGarner 3 года назад
Sure! Generally, anything you can do in Django, you can do in Celery. So, it would be as simple as fetching the data (whatever you have in mind) and then creating the model and saving it.
@wanyoikedanny472
@wanyoikedanny472 3 года назад
I did that and it worked
@ManuelBravo-Detallatucoche
@ManuelBravo-Detallatucoche 2 года назад
What version of celery and what version of python have you used?
@BennettGarner
@BennettGarner 2 года назад
requirements.txt in the linked repo shows that Celery is pinned: celery==5.2.1 I'm using Python 3.9.6
@pranjulsingh658
@pranjulsingh658 3 года назад
Hi. when I create other custom tasks and queue them up in shell, I get an importError. However, didn't get any error for debug_task. Could you please help me with this error? TA. :)
@BennettGarner
@BennettGarner 3 года назад
An import error likely means there's something wrong with how you're importing the task. Is it in another file, and are you sure the path to that file is correct in the import?
Далее
Django + Celery: Storing Results & Concurrency
20:28
How to Create a Celery Task Progress Bar in Django
21:25
진 (Jin) 'I'll Be There' Official MV
03:15
Просмотров 4,9 млн
Celery for asynchronous tasks in Django
8:46
Просмотров 7 тыс.
Getting Started With Django Celery Beat
13:07
Просмотров 12 тыс.
Mastering Django Celery and Redis || Code with SJ
22:49
Let's Learn Django - Caching with Redis
36:25
Просмотров 16 тыс.
Dockerizing Django with Postgres, Redis and Celery
20:59
Integrating Celery in Django
1:15:53
Просмотров 11 тыс.