Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Concurrency in Python
Search
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
120
PHP memory management and garbage collection
farzadghanei
1
290
Some of the ways of gathering information
farzadghanei
0
200
Statsd
farzadghanei
0
120
Introduction to StatsD
farzadghanei
0
210
Other Decks in Programming
See All in Programming
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
330
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
8
2.4k
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
6
2.2k
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
140
AIコーディングエージェント(skywork)
kondai24
0
170
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
110
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
120
ゲームの物理 剛体編
fadis
0
350
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
140
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.8k
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
4
870
これならできる!個人開発のすゝめ
tinykitten
PRO
0
110
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Bash Introduction
62gerente
615
210k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
710
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
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