Quantcast
Channel: How can I call an async function without await? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by david euler for How can I call an async function without await?

$
0
0

You can call it by multiprocessing pool.

from multiprocessing import Poolimport timedef f(x):    return x*xdef postprocess(result):    print("finished: %s" % result)if __name__ == '__main__':    pool = Pool(processes=1)              # Start a worker processes.    result = pool.apply_async(f, [10], callback=postprocess) # Evaluate "f(10)" asynchronously calling callback when finished.    print("waiting...")    time.sleep(1)

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>