Skip to Content
전문가를 위한 파이썬(2판)
book

전문가를 위한 파이썬(2판)

by 루시아누 하말류, 강권학
November 2024
Beginner to intermediate
1064 pages
25h 21m
Korean
Hanbit Media, Inc.
Content preview from 전문가를 위한 파이썬(2판)
810
4
제어 흐름
results.put(PrimeResult(0, False, 0.0)) ❿
def start_jobs(
procs: int, jobs: JobQueue, results: ResultQueue ⓫
) -> None:
for n in NUMBERS:
jobs.put(n) ⓬
for _ in range(procs):
proc = Process(target=worker, args=(jobs, results)) ⓭
proc.start() ⓮
jobs.put(0) ⓯
threading
을 모방하기 위해
multiprocessing
multiprocessing
.
SimpleQueue
를 제공하지
만, 이 메서드는 더 하위 수준인
BaseContext
클래스에 미리 정의된 인스턴스에 바인딩되었다. 우리는
SimpleQueue
를 호출해야 하지만, 자료형 힌트에는 사용할 수 없다.
❷ 자료형 힌트에 필요한
SimpleQueue
multiprocessing
.
queues
에 있다.
❸ 소수인지 검사할 숫자는
PrimeResult
에 있다.
n
과 여러 결과 필드를 함께 모아 놓으면 나중에 결과를
간단히 출력할 수 있다.
❹ 작업을 수행할 프로세스들에
main
()
함수(예제
19
-
14
)가 숫자를 전달하는 데 사용할
SimpleQueue
의 별칭이다.
main ...
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

전문가를 위한 리액트

전문가를 위한 리액트

테자스 쿠마르
고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트

Publisher Resources

ISBN: 9791169211772