def inner(f): # Function may be wrapped with no-arg decorator queue_ = 'kuyruk' if callable(queue) else queue return Task(f, self, queue=queue_, local=local, retry=retry, max_run_time=max_run_time)
def _apply_task(task: Task, args: Tuple, kwargs: Dict[str, Any]) -> Any: """Logs the time spent while running the task.""" if args is None: args = () if kwargs is None: kwargs = {} start = monotonic() try: return task.apply(*args, **kwargs) finally: delta = monotonic() - start logger.info("%s finished in %i seconds." % (task.name, delta))
def inner(f): # Function may be wrapped with no-arg decorator queue_ = 'kuyruk' if callable(queue) else queue return Task(f, self, queue_, **kwargs)
def wrapper(f: Callable) -> Task: return Task(f, self, queue, **kwargs)