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
78
Crawleando sites com NodeJS
allisson
0
140
Introdução a linguagem Go
allisson
0
290
Docker + Django
allisson
5
590
Construindo um micro framework web em Python
allisson
0
220
Consumindo API's OAuth{1,2} com Python
allisson
1
160
Deploy completo de uma aplicação Django
allisson
6
460
Desenvolvimento Web com Django
allisson
0
130
Otimizando sites com o nosql redis
allisson
4
140
Other Decks in Programming
See All in Programming
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
120
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
Criando Commits Incríveis no Git
marcelgsantos
2
170
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
890
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
370
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
ドメインイベント増えすぎ問題
h0r15h0
1
230
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
YesSQL, Process and Tooling at Scale
rocio
169
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
How to Ace a Technical Interview
jacobian
276
23k
Music & Morning Musume
bryan
46
6.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Building Adaptive Systems
keathley
38
2.3k
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