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
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
410
Django Through The Years
andrewgodwin
0
330
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
760
How To Break Django: With Async
andrewgodwin
1
840
Taking Django's ORM Async
andrewgodwin
0
870
The Long Road To Asynchrony
andrewgodwin
0
780
The Scientist & The Engineer
andrewgodwin
1
870
Other Decks in Programming
See All in Programming
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
150
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
860
信頼性の目標を誰も求めてない
shubox
0
500
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
390
スマート反転とウェブアクセシビリティ
camiha
0
180
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
ソフトウェアラスタライザ
fadis
1
800
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
240
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
110
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.4k
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
6.2k
Featured
See All Featured
HDC tutorial
michielstock
2
860
Accessibility Awareness
sabderemane
1
210
The Art of Programming - Codeland 2020
erikaheidi
57
14k
It's Worth the Effort
3n
188
29k
Why Our Code Smells
bkeepers
PRO
340
58k
Navigating Weather and Climate Data
rabernat
0
510
New Earth Scene 8
popppiees
3
2.5k
Thoughts on Productivity
jonyablonski
76
5.4k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
エンジニアに許された特別な時間の終わり
watany
108
250k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
630
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