Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ProcessPoolExecutor raises exception or hangs the process whenshutdown(wait=False) and worker throws exception #132969

Open
@ogbiggles

Description

@ogbiggles

Bug report

Bug description:

Below code demonstrates two problems that occur when
(a) worker process throws an exception, and
(b)shutdown(wait=False) is used

  1. When max_workers < number of submitted tasks, raisesexception TypeError: object of type 'NoneType' has no len()
  2. When max_workers > number of submitted tasks, raisesexception TypeError: object of type 'NoneType' has no len() AND then program hangs

There is no problem whenshutdown(wait=True) is used or if the worker processes exit cleanly.

importconcurrent.futuresimportmultiprocessingasmpimporttimedeftask(n:int)->int:ifn==2:raiseException("Not gonna do it")else:time.sleep(n)returnndefmain()->None:# max_workers=2 results in raised exception and program exits# max_workers=4 results in raised exception and program hangs#executor=concurrent.futures.ProcessPoolExecutor(max_workers=2,mp_context=mp.get_context("forkserver"),max_tasks_per_child=1    )f1=executor.submit(task,1)f2=executor.submit(task,2)f3=executor.submit(task,3)result=0try:result+=f1.result()result+=f2.result()result+=f3.result()print(f"Result ={result}")exceptExceptionase:print(f"Exception while getting result :{e}")executor.shutdown(wait=False)if__name__=="__main__":main()

CPython versions tested on:

3.12

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp