Posted in Python onOctober 14, 2018
async_call.py
#coding:utf-8 from threading import Thread def async_call(fn): def wrapper(*args, **kwargs): Thread(target=fn, args=args, kwargs=kwargs).start() return wrapper
test.py
from time import sleep from async_call import async_call class AA: @async_call def hello( self ): self.__count += 1 print(int(time.())) sleep(2) print(int(time.())) return if __name__ == "__main__": AA().hello()
以上这篇Python 实现异步调用函数的示例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。
Python 实现异步调用函数的示例讲解
- Author -
独一无二的小个性声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@