Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Async se faz - asyncio na prática
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Marco Rougeth
April 21, 2018
Technology
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Async se faz - asyncio na prática
TDC Floripa 2018
Marco Rougeth
April 21, 2018
More Decks by Marco Rougeth
See All by Marco Rougeth
Bottery
rougeth
0
56
Um Raio-X do Django
rougeth
1
190
Do Zero a Contribuição Científica com Python
rougeth
0
37
Other Decks in Technology
See All in Technology
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
190
Running Kotlin + Quarkus with Lambda
nealle
1
3.7k
go-sqletch
moznion
0
140
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
340
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
110
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
290
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.3k
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
200
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
260
会社説明資料
persolserverworks
0
9.8k
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
170
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
300
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
450
KATA
mclloyd
PRO
35
16k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
WCS-LA-2024
lcolladotor
0
890
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Building the Perfect Custom Keyboard
takai
2
910
Into the Great Unknown - MozCon
thekraken
41
2.8k
Building Applications with DynamoDB
mza
96
7.2k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Writing Fast Ruby
sferik
630
63k
Transcript
async que se faz asyncio na prática
Marco Rougeth twitter @marcorougeth github @rougeth https://rgth.co
Um amigo meu...
@Onsale > 5k membros @Rastreiobot > 18k pedidos
@Rastreiobot > 18k pedidos @Onsale > 5k membros
1. Busca pacotes no banco 2. Verificar atualizações no Correios
3. Atualiza pacotes no banco 4. Notifica usuários rotina.py
- 1 vez a cada hora - 18k pedidos rotina.py
- 1 vez a cada hora - 18k pedidos A
rotina demora mais do que 1 hora para terminar de executar rotina.py
import asyncio
This module provides infrastructure for writing single-threaded concurrent code using
coroutines, multiplexing I/O a c c e s s o v e r s o c k e t s a n d o t h e r resources, running network clients and servers, and other related primitives.
asyncio executa código assíncrono?
None
None
None
None
None
loop = asyncio.get_event_loop()
async def soma(a, b): return a + b
>>> await soma(1, 2) 3
>>> soma(1, 2) <coroutine object soma at ...>
loop.run_until_complete( soma(1, 2) )
None
def buscar_pedidos_no_banco() def checar_pedido_no_correios(pedido) def atualizar_pacote_no_banco(pedido) def notificar_usuario(pedido) def main()
def buscar_pedidos_no_banco() def checar_pedido_no_correios(pedido) def atualizar_pacote_no_banco(pedido) def notificar_usuario(pedido) def main()
executada apenas 10% das vezes
def buscar_pedidos_no_banco() def checar_pedido_no_correios(pedido) def atualizar_pacote_no_banco(pedido) def notificar_usuario(pedido) def main()
def sync_request(pedido, api) async def async_request(pedido, api) 30% 100ms 40%
500ms 20% 1.000ms 10% 10.000ms
╗ ╗ ╗ ╗ ╗ ╗ ╗ ╗ ╔══ ╗
╔═══ ╗╚══ ╔══╝╚══ ╔══╝ ╔════╝ ╔══ ╗╚ ╗ ╔╝ ╔╝ ║ ║ ║ ║ ╗ ╔╝ ╚ ╔╝ ╔══ ╗ ║ ║ ║ ║ ╔══╝ ╔══ ╗ ╚ ╔╝ ╔╝╚ ╔╝ ║ ║ ╗ ║ ║ ║ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ██████ ██████ ████████ ████████ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██ ██ ██ ██ █████ ██████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████ ██████ ██ ██ ███████ ██ ██ ██
Multiplatform Auto-reload Templates Session I18N NLP https://bottery.io
olist.com 99jobs.com/olist
Marco Rougeth twitter @marcorougeth github @rougeth https://rgth.co
Código usado na palestra: async_rotina.py https://gist.github.com/rougeth/5566c3873d8e5efd488e73c396783451 sync_rotina.py https://gist.github.com/rougeth/ae171c106be46791233fbb17ec6a61de utils.py https://gist.github.com/rougeth/70d0efd922a5f1a689696546260d3a1b