I don't understand why this code is behaving in different way. In the first case, the code will print 'elo' and after 19 seconds we will see '3'.
In other case we will be first wait 19 seconds, and after that we will see 'elo'.
Could you explain me that?
from concurrent.futures import ThreadPoolExecutor def wait_on_future(): f = 3 import time time.sleep(19) print(f) executor = ThreadPoolExecutor(max_workers=2) executor.submit(wait_on_future) print("elo") vs
from concurrent.futures import ThreadPoolExecutor def wait_on_future(): f = 3 import time time.sleep(19) print(f) with ThreadPoolExecutor(max_workers=2) as executor: executor.submit(wait_on_future) print("elo")