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 in Python
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Farzad Ghanei
March 15, 2014
Programming
10k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Concurrency in Python
Mini PyCon MY 2014
March 2014, Kuala Lumpur
Farzad Ghanei
March 15, 2014
Transcript
37 slides
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
More Decks by Farzad Ghanei
See All by Farzad Ghanei
PHP Testing and Mocking
farzadghanei
0
140
PHP memory management and garbage collection
farzadghanei
1
310
Some of the ways of gathering information
farzadghanei
0
230
Statsd
farzadghanei
0
130
Introduction to StatsD
farzadghanei
0
240
Other Decks in Programming
See All in Programming
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
320
Going Full Circle with Virtual Graphs and Relational Databases
michaelsimons
1
120
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
640
エージェントの管理もエージェントに – herdr-core と自作バックログで作る司令塔 –
nearme_tech
PRO
2
150
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
150
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
240
Debian JP Projectのサーバー構成
uwabami
1
180
AppFunctionsの内部実装を紐解く
hiroaki404
1
120
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
270
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
280
Crash Auto Pipelines
veronikapj
1
450
Featured
See All Featured
Accessibility Awareness
sabderemane
1
310
WENDY [Excerpt]
tessaabrams
15
41k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
So, you think you're a good person
axbom
PRO
2
2.3k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
540
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
The Curious Case for Waylosing
cassininazir
1
630
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
360
Navigating Weather and Climate Data
rabernat
0
600
Visualization
eitanlees
153
17k
Faster Mobile Websites
deanohume
310
32k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k