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
·
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
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
290
Some of the ways of gathering information
farzadghanei
0
220
Statsd
farzadghanei
0
120
Introduction to StatsD
farzadghanei
0
230
Other Decks in Programming
See All in Programming
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
700
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
970
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
120
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
320
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
10 Tips of AWS ~Gen AI on AWS~
licux
5
540
Building on Bluesky's AT Protocol with Ruby
mackuba
0
100
2026-04-15 Spring IO - I Can See Clearly Now
jonatan_ivanov
1
180
tRPCの概要と少しだけパフォーマンス
misoton665
2
260
when storing skills in S3 file
watany
3
1.3k
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
130
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.1k
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
A better future with KSS
kneath
240
18k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
New Earth Scene 8
popppiees
3
2.2k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
Practical Orchestrator
shlominoach
191
11k
HDC tutorial
michielstock
2
650
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