狠狠撸

狠狠撸Share a Scribd company logo
北京迅达云成科技有限公司 www.speedycloud.cn
北京迅达云成科技有限公司
www.speedycloud.cn
2015年9月 北京
WELCOME
How to Use Multi-thread &
Multi-process in Python
北京迅达云成科技有限公司 www.speedycloud.cn
Why using multi-thread?
Productivity
北京迅达云成科技有限公司 www.speedycloud.cn
Multi-thread Multi-process
Code
Review
北京迅达云成科技有限公司 www.speedycloud.cn
You Got Me!
北京迅达云成科技有限公司 www.speedycloud.cn
What is GIL?
In C-python, the global interpreter lock, or GIL, is a mutex that
prevents multiple native threads from executing Python byte-codes at
once. This lock is necessary mainly because C-Python’s memory
management is not thread-safe.(However, since the GIL exists, other
features have grown to depend on the guarantees that it enforces.)
GIL will serialize threads and stop the concurrence of threads.
北京迅达云成科技有限公司 www.speedycloud.cn
Multi-thread test
北京迅达云成科技有限公司 www.speedycloud.cn
Python multi-thread, no use at all?
NO!
北京迅达云成科技有限公司 www.speedycloud.cn
The Good News…
I/O Intensive:
北京迅达云成科技有限公司 www.speedycloud.cn
IO Intensive Running Sequence
北京迅达云成科技有限公司 www.speedycloud.cn
Unfortunately…
CPU Intensive Task: Multi-thread’s
productivity even worse than single thread
北京迅达云成科技有限公司 www.speedycloud.cn
How to deal with it?
First:
Ctypes
北京迅达云成科技有限公司 www.speedycloud.cn
Second:
multiprocessing
Extra:multiprocessing.dummy
How to deal with it?
北京迅达云成科技有限公司 www.speedycloud.cn
Been there, done that…
Join()
北京迅达云成科技有限公司 www.speedycloud.cn
file discripter
In Linux, all operations on all devices and/or files are done via file descriptor.
Been there, done that…
北京迅达云成科技有限公司 www.speedycloud.cn
北京迅达云成科技有限公司 www.speedycloud.cn
Thanks!
Beijing SpeedyCloud Technology Co., Ltd.,
www.speedycloud.cn
Ad

Recommended

PDF
Parallel programming using python
Samah Gad
?
PDF
Multiprocessing with python
Patrick Vergain
?
PPTX
Parallel Programming
Uday Sharma
?
PDF
Object-oriented Programming in Python
Juan-Manuel Gimeno
?
PDF
Memory Management In Python The Basics
Nina Zakharenko
?
PDF
An Introduction to Python Concurrency
David Beazley (Dabeaz LLC)
?
PDF
GIL - Concurrency & Parallelism in Python
Piyus Gupta
?
PPTX
SRECon19 Asia - Enhance Your Python Code Beyond GIL
Nitin Bhojwani
?
PDF
教育交互直播的技术难点与架构探索 @ 见云沙龙
SpeedyCloud
?
PPTX
选型指南:颁诲苍系统中诲苍蝉的设计与研发
SpeedyCloud
?
PPTX
浅析笔测迟丑辞苍多线程与多进程的使用
SpeedyCloud
?
PPTX
运维?KVM & OpenVZ & Docker
SpeedyCloud
?
PPT
深入顿辞肠办别谤的资源管理
SpeedyCloud
?
PPT
Resource Management of Docker
SpeedyCloud
?
PPTX
The Evolution of SpeedyCloud Resources Scheduling System
SpeedyCloud
?
PDF
SpeedyCloud 云计算平台资源调度系统要点解析
SpeedyCloud
?
PDF
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
?
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
?
PDF
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
PDF
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
?
PDF
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
?
PDF
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
?
PDF
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
?
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 狠狠撸s
Ravi Tamada
?
PDF
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
?
PPTX
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
?
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
?
PDF
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
?
PPTX
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
?

More Related Content

More from SpeedyCloud (8)

PDF
教育交互直播的技术难点与架构探索 @ 见云沙龙
SpeedyCloud
?
PPTX
选型指南:颁诲苍系统中诲苍蝉的设计与研发
SpeedyCloud
?
PPTX
浅析笔测迟丑辞苍多线程与多进程的使用
SpeedyCloud
?
PPTX
运维?KVM & OpenVZ & Docker
SpeedyCloud
?
PPT
深入顿辞肠办别谤的资源管理
SpeedyCloud
?
PPT
Resource Management of Docker
SpeedyCloud
?
PPTX
The Evolution of SpeedyCloud Resources Scheduling System
SpeedyCloud
?
PDF
SpeedyCloud 云计算平台资源调度系统要点解析
SpeedyCloud
?
教育交互直播的技术难点与架构探索 @ 见云沙龙
SpeedyCloud
?
选型指南:颁诲苍系统中诲苍蝉的设计与研发
SpeedyCloud
?
浅析笔测迟丑辞苍多线程与多进程的使用
SpeedyCloud
?
运维?KVM & OpenVZ & Docker
SpeedyCloud
?
深入顿辞肠办别谤的资源管理
SpeedyCloud
?
Resource Management of Docker
SpeedyCloud
?
The Evolution of SpeedyCloud Resources Scheduling System
SpeedyCloud
?
SpeedyCloud 云计算平台资源调度系统要点解析
SpeedyCloud
?

Recently uploaded (20)

PDF
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
?
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
?
PDF
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
PDF
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
?
PDF
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
?
PDF
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
?
PDF
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
?
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 狠狠撸s
Ravi Tamada
?
PDF
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
?
PPTX
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
?
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
?
PDF
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
?
PPTX
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
?
PDF
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
?
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
?
PDF
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
?
PDF
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
?
PDF
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
?
PDF
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
?
Python Conference Singapore - 19 Jun 2025
ninefyi
?
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
?
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
?
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
?
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?
UserCon Belgium: Honey, VMware increased my bill
stijn40
?
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) 狠狠撸s
Ravi Tamada
?
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
?
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
?
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
?
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
?
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
?
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
?
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
?
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
?
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
?
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
?
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
?
Ad

How to Use Multi-thread & Multi-process in Python