def calc():
i = 1
while i < 100000000:
i += 1
return 'result'
from concurrent.futures import ThreadPoolExecutor, run_on_executor
executor = ThreadPoolExecutor(max_worker=4)
@run_on_executor
def calc():
i = 1
while i < 100000000:
i += 1
return 'result'