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
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
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
110
Agents on Rails - Rails at Scale 2026
irinanazarova
0
280
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
200
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
140
Heart of Swift Concurrency
koher
0
1.1k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
320
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
420
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
980
SREの越境 / SRE Collaboration
y0hgi
2
290
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
460
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
3k
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
460
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Bash Introduction
62gerente
615
220k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
370
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
250
Deep Space Network (abreviated)
tonyrice
0
320
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
330
Mobile First: as difficult as doing things right
swwweet
225
10k
Ethics towards AI in product and experience design
skipperchong
2
400
Designing for Performance
lara
611
70k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Making Projects Easy
brettharned
120
6.8k
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