Even though the first example about the ThreadPoolExecutor uses the pow function ( https://docs.python.org/3/library/concurrent.futures.html ) it seems that using pow abnormally blocks all threads when called. See code below.
from concurrent.futures import ThreadPoolExecutor
import time
executor = ThreadPoolExecutor(max_workers=16)
def blocking():
i = 0
while True:
time.sleep(1)
i+=1
print("block",i)
if i>3:
print("Starting pow....")
break
block= pow(363,100000000000000)
return True
def non_blocking():
i = 0
while True:
time.sleep(1)
i+=1
print("non",i)
return True
f1 = executor.submit(blocking)
f2 = executor.submit(non_blocking)
I expected the output:
block 1
non 1
block 2
non 2
block 3
non 3
block 4
Starting pow....
non 4
non 5
non 6
non 7
non 8
but the program stops running after "starting pow...." giving the result:
block 1
non 1
block 2
non 2
block 3
non 3
block 4
Starting pow....