当前位置: 移动技术网 > IT编程>脚本编程>Python > Python 实现异步调用函数的示例讲解

Python 实现异步调用函数的示例讲解

2018年11月09日  | 移动技术网IT编程  | 我要评论

刘磬纤,换日箭txt下载,史莱姆王的体液

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 实现异步调用函数的示例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网