异步执行且不等待
- 使用线程装饰器实现
from threading import Thread
from time import sleep
def asyncc(f):
def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs)
thr.start()
return wrapper
@asyncc
def A():
sleep(10)
print("函数A睡了十秒钟。。。。。。")
print("a function")
def B():
print("b function")
def C():
A()
B()
运行结果