1
This commit is contained in:
14
app/service/utils/decorator.py
Normal file
14
app/service/utils/decorator.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import time
|
||||
import logging
|
||||
|
||||
|
||||
def RunTime(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
t1 = time.time()
|
||||
res = func(*args, **kwargs)
|
||||
t2 = time.time()
|
||||
if t2 - t1 > 0.05:
|
||||
logging.info(f"function:【{func.__name__}】,runtime:【{str(t2 - t1)}】s")
|
||||
return res
|
||||
|
||||
return wrapper
|
||||
10
app/service/utils/generate_uuid.py
Normal file
10
app/service/utils/generate_uuid.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import threading
|
||||
import uuid
|
||||
|
||||
id_lock = threading.Lock()
|
||||
|
||||
|
||||
def generate_uuid():
|
||||
with id_lock:
|
||||
unique_id = str(uuid.uuid1())
|
||||
return unique_id
|
||||
Reference in New Issue
Block a user