Используйте Threading модуль в Python:
thread = threading.Thread(target = func2, args = (i, ))
thread.start()
Попробуйте это:
import threading
import time
def func2(paraI):
time.sleep(10)
print('awaked, i = %d' % paraI)
def func1():
i = 5
# func2 will use parameter inside func1
# but func1 doesn't depend on func2
# so func2 is expected to run another thread
# and func1 will keep running (return)
print("Starting the Thread")
thread = threading.Thread(target = func2, args = (i,))
thread.start()
return i
if __name__ == "__main__":
print("Func1 returned", func1())
Выход:
Starting the Thread
Func1 returned 5
И через 10
секунд, ...
awaked, i = 5