Ir al contenido

Executor not shut down (ARCH2040)

Esta página aún no está disponible en tu idioma.

Key python.async.executor-not-shutdown · Severity warning · Category async

Creating a ThreadPoolExecutor or similar pool without calling shutdown() or using it as a context manager leaks non-daemon threads and prevents the process from exiting cleanly.

from concurrent.futures import ThreadPoolExecutor
def run(tasks):
pool = ThreadPoolExecutor(max_workers=4) # never shut down
return list(pool.map(work, tasks))
from concurrent.futures import ThreadPoolExecutor
def run(tasks):
with ThreadPoolExecutor(max_workers=4) as pool:
return list(pool.map(work, tasks))

Use the executor inside a with block, or call shutdown() when you are done with it.