Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Concurrency to Channels
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Andrew Godwin
October 08, 2017
Programming
360
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Concurrency to Channels
My keynote from Python Brasil 13 (2017).
Andrew Godwin
October 08, 2017
More Decks by Andrew Godwin
See All by Andrew Godwin
Reconciling Everything
andrewgodwin
1
420
Django Through The Years
andrewgodwin
0
340
Writing Maintainable Software At Scale
andrewgodwin
0
550
A Newcomer's Guide To Airflow's Architecture
andrewgodwin
0
430
Async, Python, and the Future
andrewgodwin
2
770
How To Break Django: With Async
andrewgodwin
1
850
Taking Django's ORM Async
andrewgodwin
0
880
The Long Road To Asynchrony
andrewgodwin
0
790
The Scientist & The Engineer
andrewgodwin
1
880
Other Decks in Programming
See All in Programming
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
380
CodeRabbitの効果検証と過ごしてみた3ヶ月
armondando
0
220
phperだってパンチカードでコーディングしたい
o0h
PRO
0
270
setup-vp GitLab対応の裏側
naokihaba
0
160
Java 27新機能 / Java 27 new features
kishida
2
220
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
180
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
350
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
480
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
360
APNsからLive Activityを開始する話
yumnumm
0
160
Featured
See All Featured
Mind Mapping
helmedeiros
1
400
For a Future-Friendly Web
brad_frost
184
10k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
HDC tutorial
michielstock
2
950
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
400
Side Projects
sachag
456
43k
The SEO Collaboration Effect
kristinabergwall1
1
590
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
610
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
WENDY [Excerpt]
tessaabrams
14
40k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.3k
Transcript
Andrew Godwin @andrewgodwin
Hi, I’m Andrew Godwin • Django core developer • Senior
Software Engineer at • South, Django migrations, Channels
What is Channels?
What is Channels?
Why Channels?
2000 2008 2015
Python 1.5 Threading 2000
Twisted 1.0 2002
WSGI (PEP 333) 2003
Python 2.6 Multiprocessing 2008
Django 1.0 2008
Eventlet / gevent 2009
Python 3.4 asyncio 2014
Python 3.5 async / await 2015
Web request handling is “solved” We have good patterns and
standards
Web request handling is easy It’s stateless, and has a
fixed response pattern
Client Server Request Response Process
Other protocols are not so easy Like WebSockets and MQTT
This is why they are more efficient No overheads of
cookies, headers and TCP handshake
Client Server Connect Data ??? Data Data Data
Writing async code is harder There’s a reason we don’t
do it all the time
Deadlocks Livelocks Race conditions Resource starvation
Simple Race Condition
Thread 1 Thread 2 if self.funds[..] < .. if self.funds[..]
< .. self.funds[..] += .. self.funds[..] -= .. self.funds[..] += .. self.funds[..] -= .. {"a": 20, "b": 0} {"a": 0, "b": 20} {"a": -20, "b": 40}
“Fixing” it, but actually adding a deadlock
Thread 1 Thread 2 get lock a get lock b
release lock b release lock a get lock b get lock a release lock a release lock b
Thread 1 Thread 2 get lock a get lock b
get lock b get lock a
More threads = more problems And hard to find in
development when you have no users
CSP “Communicating Sequential Processes” Algebra for talking about concurrency &
problems
You don’t need everything async Only the important bits
Channels: sync + async tooling Traditional synchronous Django with async
handling
“ASGI”: WSGI + async An interface that works for more
than request-response.
Goal: You mostly write sync code Channels/Django handles the annoying
part
Sync code for async behaviour
Why not just use asyncio? Do we need channels at
all?
Channels 1: Can’t write async code too Have to write
it separate outside of Channels framework
Channels 2: asyncio + sync support You can write code
as complex as you need to
Channels does not solve everything Neither does Django, the goal
is a good place to start
Working on more than just WebSocket Ways to write Django/Python
against anything with “events”
WebSockets? Emails? Chat? SMS?
What is Django in future? Is it HTTP requests forever?
Making async code easier = good Give people a way
to learn safely
Make Python the best place for these Even if it
doesn’t end up being Django.
Thanks. Andrew Godwin @andrewgodwin aeracode.org