Answer the question
In order to leave comments, you need to log in
How to convert a synchronous function into an asynchronous one?
Imagine there is a function
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'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question