Executor not shut down (ARCH2040)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
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.
Incorrect
Section titled “Incorrect”from concurrent.futures import ThreadPoolExecutor
def run(tasks): pool = ThreadPoolExecutor(max_workers=4) # never shut down return list(pool.map(work, tasks))Correct
Section titled “Correct”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.