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
3
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
270
EdgeDB & Python @ PyBay 2019
1st1
2
930
asyncio today & tomorrow
1st1
4
2.5k
async/await and why it's awesome
1st1
0
250
High performance networking in asyncio
1st1
1
470
Other Decks in Programming
See All in Programming
未来を拓くAI技術〜エージェント開発とAI駆動開発〜
leveragestech
2
160
Comparing decimals in Swift Testing
417_72ki
0
170
AIに安心して任せるためにTypeScriptで一意な型を作ろう
arfes0e2b3c
0
380
バイブコーディング × 設計思考
nogu66
0
120
AI時代のドメイン駆動設計-DDD実践におけるAI活用のあり方 / ddd-in-ai-era
minodriven
21
8.5k
「リーダーは意思決定する人」って本当?~ 学びを現場で活かす、リーダー4ヶ月目の試行錯誤 ~
marina1017
0
230
管你要 trace 什麼、bpftrace 用下去就對了 — COSCUP 2025
shunghsiyu
0
430
実践!App Intents対応
yuukiw00w
1
310
CEDEC 2025 『ゲームにおけるリアルタイム通信への QUIC導入事例の紹介』
segadevtech
3
920
レガシープロジェクトで最大限AIの恩恵を受けられるようClaude Codeを利用する
tk1351
2
330
The State of Fluid (2025)
s2b
0
180
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
2
390
Featured
See All Featured
Side Projects
sachag
455
43k
A better future with KSS
kneath
239
17k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Embracing the Ebb and Flow
colly
86
4.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Building Adaptive Systems
keathley
43
2.7k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
GitHub's CSS Performance
jonrohan
1031
460k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
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!