def reinit(cluster_name: str, group: Optional[int], member_names: List[str], force: bool, wait: bool) -> None:
    """Process ``reinit`` command of ``patronictl`` utility.

    Reinitialize cluster members based on given filters.

    .. note::
        Only reinitialize replica members, not a leader.

    :param cluster_name: name of the Patroni cluster.
    :param group: filter which Citus group we should reinit members. Refer to the module note for more details.
    :param member_names: name of the members that should be reinitialized.
    :param force: perform the restart without asking for confirmations.
    :param wait: wait for the operation to complete.
    """
    cluster = get_dcs(cluster_name, group).get_cluster()
    members = get_members(cluster, cluster_name, member_names, CtlPostgresqlRole.REPLICA,
                          force, 'reinitialize', group=group)

    wait_on_members: List[Member] = []
    for member in members:
        body: Dict[str, bool] = {'force': force}
        while True:
            r = request_patroni(member, 'post', 'reinitialize', body)
            started = check_response(r, member.name, 'reinitialize')
            if not started and r.data.endswith(b' already in progress') \
                    and not force and click.confirm('Do you want to cancel it and reinitialize anyway?'):
                body['force'] = True
                continue
            break
        if started and wait:
            wait_on_members.append(member)

    last_display = []
    while wait_on_members:
        if wait_on_members != last_display:
            click.echo('Waiting for reinitialize to complete on: {0}'.format(
                ", ".join(member.name for member in wait_on_members))
            )
            last_display[:] = wait_on_members
        time.sleep(2)
        for member in wait_on_members:
            data = json.loads(request_patroni(member, 'get', 'patroni').data.decode('utf-8'))
            if data.get('state') != PostgresqlState.CREATING_REPLICA:
                click.echo('Reinitialize is completed on: {0}'.format(member.name))
                wait_on_members.remove(member)
Process ``reinit`` command of ``patronictl`` utility.

    Reinitialize cluster members based on given filters.

    .. note::
        Only reinitialize replica members, not a leader.

    :param cluster_name: name of the Patroni cluster.
    :param group: filter which Citus group we should reinit members. Refer to the module note for more details.
    :param member_names: name of the members that should be reinitialized.
    :param force: perform the restart without asking for confirmations.
    :param wait: wait for the operation to complete.
    
patroni/ctl.py