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
270
EdgeDB & Python @ PyBay 2019
1st1
2
950
asyncio today & tomorrow
1st1
4
2.6k
async/await and why it's awesome
1st1
0
260
High performance networking in asyncio
1st1
1
510
Other Decks in Programming
See All in Programming
さぁV100、メモリをお食べ・・・
nilpe
0
150
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
170
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
300
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
はてなアカウント基盤 State of the Union
cockscomb
0
250
Lessons from Spec-Driven Development
simas
PRO
0
220
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
230
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
280
ふつうのFeature Flag実践入門
irof
8
4.2k
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
12
5.6k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
How to build a perfect <img>
jonoalderson
1
5.7k
How to Talk to Developers About Accessibility
jct
2
240
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Become a Pro
speakerdeck
PRO
31
6k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
860
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Six Lessons from altMBA
skipperchong
29
4.3k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
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!