The easy way would be to run it in a thread:
import threading def do_something_and_move_on(): pass worker = threading.Thread(target=do_something_and_move_on) worker.start() # now do other things while it runs... # then join the worker, to make sure it's done before the script ends worker.join()The more complicated answer would be to write your code using async/await, and let the asyncio library handle it for you. But that's harder to do if you already have code that you don't want to mess with.