帝王谷资源网 Design By www.wdxyy.com

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,异步调用,函数

帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com