Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tarefas assíncronas com django e celery
Search
Allisson Azevedo
June 11, 2013
Programming
1
24k
Tarefas assíncronas com django e celery
Slides da palestra no mutirão python:
https://plus.google.com/events/c4a18aljra59dqf56t1lac89o4k
Allisson Azevedo
June 11, 2013
Tweet
Share
More Decks by Allisson Azevedo
See All by Allisson Azevedo
Programação Assíncrona com Asyncio
allisson
0
120
Crawleando sites com NodeJS
allisson
0
170
Introdução a linguagem Go
allisson
0
320
Docker + Django
allisson
5
660
Construindo um micro framework web em Python
allisson
0
240
Consumindo API's OAuth{1,2} com Python
allisson
1
200
Deploy completo de uma aplicação Django
allisson
6
520
Desenvolvimento Web com Django
allisson
0
150
Otimizando sites com o nosql redis
allisson
4
180
Other Decks in Programming
See All in Programming
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.3k
Python札幌 LT資料
t3tra
7
1.1k
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
CSC307 Lecture 04
javiergs
PRO
0
650
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
670
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1k
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
370
Apache Iceberg V3 and migration to V3
tomtanaka
0
120
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
710
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
410
Package Management Learnings from Homebrew
mikemcquaid
0
170
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
160
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
420
Being A Developer After 40
akosma
91
590k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Google's AI Overviews - The New Search
badams
0
900
Speed Design
sergeychernyshev
33
1.5k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
110
How STYLIGHT went responsive
nonsquared
100
6k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Transcript
TAREFAS ASSÍNCRONAS COM DJANGO E CELERY Allisson Azevedo Monday, June
10, 13
ALLISSON AZEVEDO Graduado em Licenciatura em Computação Desenvolvedor Web http://speakerdeck.com/allisson
http://slideshare.net/allisson http://github.com/allisson http://youtube.com/user/allissonazevedo Monday, June 10, 13
Monday, June 10, 13
Monday, June 10, 13
PORQUE EU PRECISO DE UM TASK/JOB QUEUE? Necessidade de processar
uma tarefa fora do ciclo de requisição e reposta Processamento de vídeo/imagens Envio de e-mails Geração de relatórios complexos Comunicação com API’s externas (twitter, facebook) Monday, June 10, 13
PORQUE EU PRECISO DE UM TASK/JOB QUEUE? Agendar tarefas (substituir
o cron) Trabalhar com indexação de um search engine Monday, June 10, 13
COMO FUNCIONA? Client Quem gera a tarefa Message Broker Gerencia
a fila de tarefas Worker Recebe as tarefas do Broker e executa as mesmas Monday, June 10, 13
COMO FUNCIONA? Result Store Onde são guardados os resultados das
tarefas Monday, June 10, 13
CELERY “Distributed Task Queue” Escrito em python Integração com os
principais frameworks python (django, pyramid, flask, web2py, tornado) Broker Backends (rabbitmq, redis, sqlalchemy, django, mongodb) Result Store Backends (Redis, memcached, MongoDB) Monday, June 10, 13
QUAL BROKER USAR? RabbitMQ (http://stackoverflow.com/a/9176046) Redis Não use o broker
como result store Monday, June 10, 13
INTEGRANDO COM O DJANGO pip install django-celery Adicione o djcelery
no INSTALLED_APPS Adicione as linhas no settings.py import djcelery djcelery.setup_loader() Monday, June 10, 13
INTEGRANDO COM O DJANGO Selecione o broker BROKER_URL = 'redis://localhost:6379/0'
#Redis Inicie o worker python manage.py celery worker --loglevel=info Monday, June 10, 13
INTEGRANDO COM O DJANGO Em seus projetos, crie um arquivo
chamado tasks.py Monday, June 10, 13
INTEGRANDO COM O DJANGO from celery import task @task() def
add(x, y): return x + y Monday, June 10, 13
INTEGRANDO COM O DJANGO Rode a task Monday, June 10,
13
INTEGRANDO COM O DJANGO >>> from celerytest.tasks import add >>>
add.delay(2, 2) >>> add.apply_async((2, 2)) Monday, June 10, 13
MÃO NA MASSA! https://github.com/allisson/django-social-monitor- example Monday, June 10, 13
Monday, June 10, 13
OBRIGADO! Monday, June 10, 13