안녕하세요. worker 관련 질문입니다.
worker를 최소 10에서 work_list 개수로 구하셨는데
cpu와 worker 관련 개수 구하는 혹은 판단 할수 있는 기준이 무엇인지 알수 있을까요?
답변 1
0
네 안녕하세요. jin님
상당히 좋은 질문을 해주셨습니다.
공식 레퍼런스를 보면 파이썬 버전마다 동작 방식이 모두 다른것을 확인하실 수 있어요.
최근 CPU들이 기본 코어개수가 늘어나고 가격도 저렴해진 관계로 3.8부터는 디폴트로 아래 내용을 보시면
최소 5개부터 할당되는 것을 확인하실 수 있습니다. 물론 운영체제의 현재 동작 환경에 따라서 달라지겠지요.
해당 내용은 아래 레퍼런스에서 WORKER 등으로 검색하셔서 한글로 보시면 자세하게 확인 가능합니다.
https://docs.python.org/3/library/concurrent.futures.html
class concurrent.futures.ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())
An Executor subclass that uses a pool of at most max_workers threads to execute calls asynchronously.
initializer is an optional callable that is called at the start of each worker thread; initargs is a tuple of arguments passed to the initializer. Should initializer raise an exception, all currently pending jobs will raise a BrokenThreadPool, as well as any attempt to submit more jobs to the pool.
Changed in version 3.5: If max_workers is None or not given, it will default to the number of processors on the machine, multiplied by 5, assuming that ThreadPoolExecutor is often used to overlap I/O instead of CPU work and the number of workers should be higher than the number of workers for ProcessPoolExecutor.
New in version 3.6: The thread_name_prefix argument was added to allow users to control the threading.Thread names for worker threads created by the pool for easier debugging.
Changed in version 3.7: Added the initializer and initargs arguments.
Changed in version 3.8: Default value of max_workers is changed to min(32, os.cpu_count() + 4). This default value preserves at least 5 workers for I/O bound tasks. It utilizes at most 32 CPU cores for CPU bound tasks which release the GIL. And it avoids using very large resources implicitly on many-core machines.
진도미확인 (진도가 안 넘어감)
0
41
1
RuntimeError: There is no current event loop in thread 'MainThread'
0
84
1
chapter 07-01 실행 오류
0
67
1
Chapter05-04 : sum_func의 합이 이중 출력됩니다.
0
78
2
45. 병렬성 2 - Futures(5-1) wait가 의도된 대로 동작하지 않습니다.
0
93
2
멀티스레딩 - 44. 병렬성 1 - Futures(4-2)
0
71
2
chapter05_02 클로저 질문사항 !
0
53
1
LV1 설정
0
88
2
매직 메소드의 호출 방법 차이 문의
0
133
2
왜 numbers리스트를 만들때 str으로 숫자를 감싸나요?
0
96
2
스크랩핑 실습 중 Mac OS 인증서 문제
0
129
1
AsyncIO 멀티 스크랩핑 실습 예제 관련 질문
0
168
1
강의자료가 영상과 다릅니다
0
256
2
closure.cell_contents 초기화 하기 문의
0
131
2
map함수 사용 시, list변환 방법 문의
0
337
2
__mul__ 백터 * 숫지, 백터 * 백터 처리
0
144
1
del처리후 질문입니다.
0
154
1
car_list(car1,car2,car3) 인스턴스 tuple 타입 문의
0
224
1
coroutine에 대한 질문
0
243
1
제너레이터 이터레이터 질문이 있습니다.
0
250
1
atom install package search not working
0
277
1
Magic Method - Not Implemented
0
401
1
가상환경 질문!
0
405
1
병렬처리 추가 질문이 있습니다.
0
246
1





