import multiprocessing import gc import _thread import threading before = _thread._count(), threading._dangling.copy() q = multiprocessing.Queue() q.put(1) x = q.get() q = None # oops, I didn't close the queue and I didn't join the thread! gc.collect() after = _thread._count(), threading._dangling.copy() print("number of thread diff: %+i" % (after[0] - before[0])) if after[1] != before[1]: print("dangling threads!") print("before:", list(before[1])) print("after:", list(after[1]))