def _run_task_core(task, args, kwargs): if task: if args: task(* args) elif kwargs: task(** kwargs) else: task()