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
2.3k
3
Share
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
500
Other Decks in Programming
See All in Programming
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
510
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
150
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
770
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
200
2026-04-15 Spring IO - I Can See Clearly Now
jonatan_ivanov
1
210
Firefoxにコントリビューションして得られた学び
ken7253
2
160
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
3
920
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
700
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
340
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
190
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
170
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
Building Flexible Design Systems
yeseniaperezcruz
330
40k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
200
How to train your dragon (web standard)
notwaldorf
97
6.6k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
560
Git: the NoSQL Database
bkeepers
PRO
432
67k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
54k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
410
How to build a perfect <img>
jonoalderson
1
5.5k
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!