In code:
import concurrent.futures import time def f(): time.sleep(5) ids = [1, 2] with concurrent.futures.ThreadPoolExecutor(max_workers=len(ids)) as ex