$30 off During Our Annual Pro Sale. View Details »
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
110
Crawleando sites com NodeJS
allisson
0
170
Introdução a linguagem Go
allisson
0
310
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
190
Deploy completo de uma aplicação Django
allisson
6
510
Desenvolvimento Web com Django
allisson
0
140
Otimizando sites com o nosql redis
allisson
4
170
Other Decks in Programming
See All in Programming
AIコーディングエージェント(NotebookLM)
kondai24
0
220
GISエンジニアから見たLINKSデータ
nokonoko1203
0
180
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
110
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
460
Patterns of Patterns
denyspoltorak
0
260
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
630
Deno Tunnel を使ってみた話
kamekyame
0
230
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
160
Vibe codingでおすすめの言語と開発手法
uyuki234
0
110
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
130
Jetpack XR SDKから紐解くAndroid XR開発と技術選定のヒント / about-androidxr-and-jetpack-xr-sdk
drumath2237
1
180
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
960
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
370
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
170
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
210
Reality Check: Gamification 10 Years Later
codingconduct
0
1.9k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
57
37k
Color Theory Basics | Prateek | Gurzu
gurzu
0
150
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
30 Presentation Tips
portentint
PRO
1
170
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
0
130
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