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
async/await and asyncio in Python 3.6 and beyond
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yury Selivanov
May 21, 2017
Programming
2.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
async/await and asyncio in Python 3.6 and beyond
Video of the talk:
https://www.youtube.com/watch?v=2ZFFv-wZ8_g
Yury Selivanov
May 21, 2017
More Decks by Yury Selivanov
See All by Yury Selivanov
EdgeDB–PyBay 2022
1st1
0
280
EdgeDB & Python @ PyBay 2019
1st1
2
960
asyncio today & tomorrow
1st1
4
2.6k
async/await and why it's awesome
1st1
0
270
High performance networking in asyncio
1st1
1
520
Other Decks in Programming
See All in Programming
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
380
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
880
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
180
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
480
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
500
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
310
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.4k
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
150
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
670
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
680
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
150
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
340
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
590
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
440
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Chasing Engaging Ingredients in Design
codingconduct
0
260
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
450
A designer walks into a library…
pauljervisheath
211
24k
Building Applications with DynamoDB
mza
96
7.2k
Designing for Timeless Needs
cassininazir
1
440
Statistics for Hackers
jakevdp
799
230k
Transcript
async/await and asyncio in Python 3.6 and beyond Yury Selivanov
@1st1
[email protected]
PyCon US 2017
About me Core developer since 2013 PEPs: 362, 492, 525,
530 asyncio/uvloop/asyncpg MagicStack -> magic.io
Let’s talk about async/await.
Why async/await? Other Ways threads; callbacks / promises; generators with
‘yield from’. gevent / eventlet / stackless;
Why async/await? Readability Better than callbacks or Promises; Easier to
reason about than with threads or gevent code; Promotes better patterns: message passing.
Why async/await? Theory Practice Multithreading
Why async/await? Efficiency No threads: no GIL problem; Less memory
per connection; Can handle thousands of long lasting connections.
What is async/await? Syntax: new in 3.5
What is async/await? Syntax: new in 3.6
What is async/await? Syntax: 3.7 (maybe)
What is async/await? Protocol Based on iterator protocol; __await__; __aiter__,
__anext__; __aenter__, __aexit__.
How to async/await? Frameworks OS Python Interpreter Async Framework Application
Framework Application
How to async/await? Twisted and Tornado Twisted is the mother
of async in Python; both own big ecosystems and mindshare; can/will run on top of asyncio.
How to async/await? Twisted and Tornado
How to async/await? Curio and Trio explore new approaches; (influence
asyncio) make async easier to use; not mainstream.
Let’s talk about asyncio.
What is asyncio? Foundation low-level APIs; async/await; here to stay;
pluggable event loop.
What is asyncio? Low-level APIs Transports and Protocols; network, subprocesses,
signals. callbacks;
What is asyncio? async/await streams, sockets, subprocesses, locks, timeouts. run
coroutines;
What is asyncio? Mainstream healthy ecosystem; HTTP: aiohttp and Sanic;
stable and forever supported; DBs: asyncpg, aio-libs, etc.
What is asyncio? Pluggable event loop uvloop: make asyncio 2-4
times faster.
PyO 3
What is asyncio? Pluggable event loop github.com/pyo3: Tokio; Rust meets
Python; incomplete and experimental; aims for safety and performance.
What’s next for asyncio?
What’s next? Goals for 3.7 maybe curio and trio can
be (re-)built on top of asyncio? run/use Twisted on/in asyncio; that Rust loop…
What’s next? Usability Documentation overhaul in 3.7
What’s next? Usability: now asyncio.get_event_loop() loop.create_task() loop.run_until_complete() loop.run_forever() asyncio.gather() loop.run_in_executor()
What’s next? Usability: now asyncio.get_event_loop() in Python 3.6 is predictable
in async functions pass event loop explicitly
What’s next? Usability: in 3.7? asyncio.get_event_loop() loop.create_task() loop.run_until_complete() loop.run_forever() asyncio.gather()
loop.run_in_executor()
What’s next? More New Things? start_tls() Call / Task Context
async REPL
What’s next? We Need Your Help Ask for new features!
bugs.python.org python-tulip mailing list GitHub!
Thank you!