pyiron/executorlib

[bug] PoolExecutor.shutdown(wait=True) doesn't actually wait

Closed this issue · 1 comments

pmrv commented

When queuing some functions and then (attempting) to wait on them with the shutdown function, the executor doesn't actually wait until all futures are ready. MWE is below. Doing it inside a context manager made no difference. When adding an additional time.sleep before shutting down the done callbacks do fire, so it sounds as if it's just the executor is not checking whether there are still outstanding futures.

import time
from pympipool import PoolExecutor

def calc(n):
    time.sleep(5)
    return n**2

exe = PoolExecutor(max_workers=4)
f1 = exe.submit(calc, 42)
f2 = exe.submit(calc, 84)
f1.add_done_callback(print)
f2.add_done_callback(print)
exe.shutdown(wait=True)

@pmrv this issue is fixed in #104 . I added you example above as additional test case. Maybe you can quickly test if it works for you and then we can merge it and release a new pympipool version.