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
2
10k
Concurrency in Python
Mini PyCon MY 2014
March 2014, Kuala Lumpur
Farzad Ghanei
March 15, 2014
Tweet
Share
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
210
Other Decks in Programming
See All in Programming
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
690
CSC307 Lecture 01
javiergs
PRO
0
690
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
170
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2k
ぼくの開発環境2026
yuzneri
0
110
CSC307 Lecture 04
javiergs
PRO
0
660
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
420
Fluid Templating in TYPO3 14
s2b
0
130
Featured
See All Featured
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
The agentic SEO stack - context over prompts
schlessera
0
630
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
110
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
290
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
54
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
430
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Site-Speed That Sticks
csswizardry
13
1.1k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
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