Python 官方文档:入门教程 => 点击学习
async_call.py #coding:utf-8 from threading import Thread def async_call(fn): def wrapper(*args, **kwargs):
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()
--结束END--
本文标题: Python 实现异步调用函数
本文链接: https://lsjlt.com/news/187404.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0