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
Yury Selivanov
May 21, 2017
Programming
4
2.2k
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
Tweet
Share
More Decks by Yury Selivanov
See All by Yury Selivanov
EdgeDB–PyBay 2022
1st1
0
260
EdgeDB & Python @ PyBay 2019
1st1
2
920
asyncio today & tomorrow
1st1
5
2.5k
async/await and why it's awesome
1st1
0
250
High performance networking in asyncio
1st1
1
450
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
240
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
103 Early Hints
sugi_0000
1
230
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
Recoilを剥がしている話
kirik
5
6.7k
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
3
380
선언형 UI에서의 상태관리
l2hyunwoo
0
160
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Side Projects
sachag
452
42k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
GitHub's CSS Performance
jonrohan
1030
460k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
A better future with KSS
kneath
238
17k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Typedesign – Prime Four
hannesfritz
40
2.4k
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!