def close_db(fn): """Decorator to be used with tasks that may operate on the database.""" @wraps(fn) def inner(*args, **kwargs): try: return fn(*args, **kwargs) finally: if not HUEY.immediate: close_old_connections() return inner def db_task(*args, **kwargs): def decorator(fn): ret = task(*args, **kwargs)(close_db(fn)) ret.call_local = fn return ret return decorator
Собственно вопрос по конструкции
ret = task(*args, **kwargs)(close_db(fn))