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
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
210
Statsd
farzadghanei
0
120
Introduction to StatsD
farzadghanei
0
220
Other Decks in Programming
See All in Programming
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
110
Running Swift without an OS
kishikawakatsumi
0
830
実践CRDT
tamadeveloper
0
550
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
130
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
320
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
480
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
330
AI-DLC Deep Dive
yuukiyo
8
3.5k
「速くなった気がする」をデータで疑う
senleaf24
0
170
ファインチューニングせずメインコンペを解く方法
pokutuna
0
310
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
260
10 Tips of AWS ~Gen AI on AWS~
licux
5
380
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.3k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
880
Amusing Abliteration
ianozsvald
1
150
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
180
The Spectacular Lies of Maps
axbom
PRO
1
700
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
A designer walks into a library…
pauljervisheath
211
24k
We Are The Robots
honzajavorek
0
210
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
420
How to make the Groovebox
asonas
2
2.1k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
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