This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
RequestCounter/app/decorators.py
T

25 lines
539 B
Python
Raw Normal View History

2022-04-05 20:48:50 +08:00
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/4/5
# @File Name: decorators.py
import time
from functools import wraps
def time_it(func):
@wraps(func)
def wrapper(*args, **kwargs):
2022-04-07 21:53:04 +08:00
print('I: 数据库文件开始下载')
2022-04-05 20:48:50 +08:00
start = time.time()
result = func(*args, **kwargs)
end = time.time()
2022-04-07 21:53:04 +08:00
print('I: 下载结束, 耗时 {} 秒'.format(round(end - start, 2)))
2022-04-05 20:48:50 +08:00
return result
return wrapper