Aller au contenu

Thread without join (ARCH2041)

Ce contenu n’est pas encore disponible dans votre langue.

Key python.async.thread-without-join · Severity warning · Category async

When a thread is created and started with no corresponding join(), the spawning scope may exit before the thread finishes and the thread’s exceptions vanish unobserved.

import threading
def process(items):
t = threading.Thread(target=work, args=(items,))
t.start() # no join, work unobserved
import threading
def process(items):
t = threading.Thread(target=work, args=(items,))
t.start()
t.join() # wait for completion

Call join() for every thread you start, or manage daemon lifetimes explicitly.