blob: 83a06a4860e7b934f53022f7fd0dde0967f0c3d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from threading import Thread
from functools import wraps
from flask_login import login_required
def async(f):
"""
This decorator enables to launch a task (for examle sending an email or
indexing the database) in background.
This prevent the server to freeze.
"""
def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs)
thr.start()
return wrapper
def pyagg_default_decorator(func):
@login_required
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
|