(func)
| 49 | raise SyntaxError("Must set crontab or interval one") |
| 50 | |
| 51 | def decorate(func): |
| 52 | if crontab is None and interval is None: |
| 53 | raise SyntaxError("Interval and crontab must set one") |
| 54 | |
| 55 | # Because when this decorator run, the task was not created, |
| 56 | # So we can't use func.name |
| 57 | task = '{func.__module__}.{func.__name__}'.format(func=func) |
| 58 | _name = name if name else task |
| 59 | add_register_period_task({ |
| 60 | _name: { |
| 61 | 'task': task, |
| 62 | 'interval': interval, |
| 63 | 'crontab': crontab, |
| 64 | 'args': args, |
| 65 | 'kwargs': kwargs if kwargs else {}, |
| 66 | 'description': description |
| 67 | } |
| 68 | }) |
| 69 | |
| 70 | @wraps(func) |
| 71 | def wrapper(*args, **kwargs): |
| 72 | return func(*args, **kwargs) |
| 73 | |
| 74 | return wrapper |
| 75 | |
| 76 | return decorate |
| 77 |
nothing calls this directly
no test coverage detected