async_call.py
#coding:utf-8from threading import Threaddef async_call(fn): def wrapper(*args, **kwargs): Thread(target=fn, args=args, kwargs=kwargs).start() return wrapper
test.py
from time import sleepfrom async_call import async_callclass AA: @async_call def hello( self ): self.__count += 1 print(int(time.())) sleep(2) print(int(time.())) returnif __name__ == "__main__": AA().hello()
以上这篇Python 实现异步调用函数的示例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林站长站。
新闻热点
疑难解答