Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
고성능 파이썬(2판)
by
오현석
,
미샤 고렐릭
,
이안 오스발트
May 2021
Beginner to intermediate
528 pages
11h 27m
Korean
Hanbit Media, Inc.
Content preview from
고성능 파이썬(2판)
369
9
장
multiprocessing 모듈
9.7.2
값에 락 걸기
multiprocessing
모듈은 프로세스 간에 파이썬 객체를 공유하는 방법을 몇 가지 제공한다.
원시 파이썬 객체를 낮은 통신 부가비용을 들여서 공유할 수도 있고,
Manager
를 사용해 고수
준 파이썬 객체
(
사전, 리스트 등
)
를 공유할 수도 있다
(
하지만 동기화 비용 때문에 데이터 공유
속도가 상당히 느려진다
).
여기서 우리는
multiprocessing
.
Value
객체
(
http
://
bit
.
ly
/
value
_
doc
)
를 사용해 프로
세스 사이에 정수를 하나 공유할 것이다.
Value
에는 락이 있지만, 여러분이 원하는 락과는 상
당히 다를 것이다. 동시 읽기와 쓰기를 막지만, 원자적인 값 증가를 제공하지는
않는다
. [예제
9
-
41
]은 이를 보여준다. 프로그램이 잘못된 카운터 값으로 끝난다. 이는 앞에서 봤던 동기화
를 사용하지 않는 파일 기반 예제와 비슷하다.
예제
9-41
락을 사용하지 않아서 잘못된 카운터 값이 나옴
$
python ex2_nolock.py
Expecting to see a count of 4000
We have counted to 2340
$
python -m timeit -s
"
import ex2_nolock
"
"
ex2_nolock.run_workers()
"
20 loops, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
이펙티브 타입스크립트
Dan Vanderkam
전문가를 위한 파이썬(2판)
루시아누 하말류
엑셀이 편해지는 파이썬
펠릭스 춤슈타인
핸즈온 비지도 학습
강재원, 권재철, 안쿠르 A. 파텔
Publisher Resources
ISBN: 9791162244210