def exec_task(task_path, data):
if not data:<EOL><INDENT>data = {'<STR_LIT:data>': None, '<STR_LIT:path>': task_path}<EOL><DEDENT>elif not isinstance(data, (str, bytes)):<EOL><INDENT>data = {'<STR_LIT:data>': json.dumps(data, cls=RequestJSONEncoder),<EOL>'<STR_LIT:path>': task_path}<EOL><DEDENT>else:<EOL><INDENT>if data is not None and data.startswith("<STR_LIT>"):<EOL><INDENT>with open(data[len("<STR_LIT>"):]) as f:<EOL><INDENT>data = f.read()<EOL><DEDENT><DEDENT>data = {'<STR_LIT:data>': data, '<STR_LIT:path>': task_path}<EOL><DEDENT>job = Job(data)<EOL>(task, task_callable) = create_task(task_path)<EOL>with delegating_job_context(job, task, task_callable) as jc:<EOL><INDENT>return jc.task_callable(jc.task_data)<EOL><DEDENT>
Execute task.

    :param task_path: task path
    :type task_path: str|Callable
    :param data: task's data
    :type data: Any
    :return: