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)