def split_crawl_tasks(tasks, concurrency):
if any(tasks) and isinstance(tasks[<NUM_LIT:0>], list):<EOL><INDENT>for seq in tasks:<EOL><INDENT>if not isinstance(seq, list):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if concurrency > <NUM_LIT:1>:<EOL><INDENT>chain_size = int(ceil(float(len(tasks)) / concurrency))<EOL>tasks = [<EOL>chunk for chunk in<EOL>chunks(<EOL>iter(tasks),<EOL>max(<NUM_LIT:1>, chain_size)<EOL>)<EOL>]<EOL><DEDENT>else:<EOL><INDENT>tasks = [tasks]<EOL><DEDENT><DEDENT>return tasks<EOL>
Reorganize tasks according to the tasks max concurrency value.

    :param tasks:
      sub-tasks to execute, can be either a list of tasks of a list of list
      of tasks
    :param int concurrency:
      Maximum number of tasks that might be executed in parallel.

    :return:
      list of list of tasks.