• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    미해결

ProcessPoolExecutor 사용 시 pid 증가

23.07.06 15:40 작성 23.07.06 16:51 수정 조회수 192

0

안녕하세요 강사님,

ProcessPoolExecutor를 이용해서 아래와 같이 코드를 작성했는데요, return된 pid를 출력해보면 계속 증가하는 모습을 보이는데, python에서 할당받은 pid range 내에서만 반복되는 걸까요??? 이렇게 계속 증가하는게 별다른 문제는 되지 않을까요?

try:
    while True:
                with ProcessPoolExecutor(max_workers=6) as ex:
                    processes = {}
                    # submit tasks to the pool          
                    processes.update({ex.submit(self.hello, time)})

                    for future in as_completed(processes, timeout=3):
                        # check for a failure
                        if future.exception():
                            # report progress
                            LOG.error("Failed get %s", processes[future])

                        data = future.result()
                        module = processes[future]
                        pid = data

답변 1

답변을 작성해보세요.

0

네 운영체제 -> 할당받은 프로세스를 사용하는 것이예요

무제한으로는 사용할 수 없고 max 값을 활용해서 limit 설정 후 사용하는 게 보편적인 활용방법이예요.

내가 처리하려는 작업의 처리량을 작은 단위부터 테스트 하면서 최적의 시간을 찾아가는 과정이라고

보시면 될 것 같습니다.

감사합니다 그럼 파이썬에서 생성한 프로세스의 pid allocation은 일정 range내에서 circular로 돌아가게 되는건가요??