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
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
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
300
Some of the ways of gathering information
farzadghanei
0
230
Statsd
farzadghanei
0
130
Introduction to StatsD
farzadghanei
0
230
Other Decks in Programming
See All in Programming
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
130
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
470
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
740
VibeCodingからAgenticWorkflowへ
starfish719
0
150
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
810
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
120
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.3k
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
今さら聞けない .NET CLI
htkym
0
180
Android CLI
fornewid
0
210
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
190
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
460
Ethics towards AI in product and experience design
skipperchong
2
340
The Art of Programming - Codeland 2020
erikaheidi
57
14k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
760
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
The Cost Of JavaScript in 2023
addyosmani
55
10k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
67
56k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
WCS-LA-2024
lcolladotor
0
790
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