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
Concurrency in Python
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Farzad Ghanei
March 15, 2014
Programming
2
10k
Concurrency in Python
Mini PyCon MY 2014
March 2014, Kuala Lumpur
Farzad Ghanei
March 15, 2014
Tweet
Share
More Decks by Farzad Ghanei
See All by Farzad Ghanei
PHP Testing and Mocking
farzadghanei
0
130
PHP memory management and garbage collection
farzadghanei
1
290
Some of the ways of gathering information
farzadghanei
0
210
Statsd
farzadghanei
0
120
Introduction to StatsD
farzadghanei
0
210
Other Decks in Programming
See All in Programming
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
420
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
680
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
590
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
150
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
250
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
970
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.3k
Thoughts on Productivity
jonyablonski
74
5k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Designing for Timeless Needs
cassininazir
0
130
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Testing 201, or: Great Expectations
jmmastey
46
8k
Scaling GitHub
holman
464
140k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
750
A Tale of Four Properties
chriscoyier
162
24k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
Transcript
Concurrency In Python Farzad Ghanei www.ghanei.net
!= Parallel computing Concurrency == Handling tasks while others are
still running
Blocked by IO Why? Processing takes long
Threads Solutions Processes Coroutines
Code Outline
Simple, sync IO API Threads Preemptive scheduling by OS Unpredictable
execution ordering
IO bound threads
None
CPU bound threads
CPU bound threads
None
Threads release and acquire GIL Global Interpreter Lock The one
thread that has GIL runs at a time
1 CPU bound thread
3 CPU bound threads
Not good for CPU bound Threads Good for user Interactivity,
maybe IO Shared state might cause difficulties
Simple, sync IO API Processes Preemptive scheduling by OS Unpredictable
execution ordering
IO bound processes
CPU bound processes
CPU bound processes
None
Processes Good for parallel processing Use more resources than threads
Shared state might cause difficulties
Predictable execution ordering Coroutines Cooperative concurrency
PEP 380 (yield from) Coroutines Generators (yield) Greenlets (green threads)
CPU bound greenlets
CPU bound greenlets
None
Coroutines Have early results Controlling execution
Async IO No blocking calls Respond to IO Events
Event driven concurrency Callback based (Twisted) Coroutine based (Gevent) Both
(asyncio)
Gevent Implicit coroutines (using greenlets) threading like API Monkey patching
libev event loop
Gevent
None
Twisted Explicit event loop Batteries included Deferreds No blocking calls
Twisted
None
asyncio (tulip) PEP 3156 (asyncio) Callbacks and coroutines API Standard
library Explicit event loop
Thanks