def collect_hosts(hosts, randomize=True):
    """
    Collects a comma-separated set of hosts (host:port) and optionally
    randomize the returned list.
    """

    if isinstance(hosts, six.string_types):
        hosts = hosts.strip().split(',')

    result = []
    for host_port in hosts:

        res = host_port.split(':')
        host = res[0]
        port = int(res[1]) if len(res) > 1 else DEFAULT_KAFKA_PORT
        result.append((host.strip(), port))

    if randomize:
        shuffle(result)

    return result
def collect_hosts ( hosts , randomize = True ) : if isinstance ( hosts , six . string_types ) : hosts = hosts . strip ( ) . split ( ',' ) result = [ ] for host_port in hosts : res = host_port . split ( ':' ) host = res [ 0 ] port = int ( res [ 1 ] ) if len ( res ) > 1 else DEFAULT_KAFKA_PORT result . append ( ( host . strip ( ) , port ) ) if randomize : shuffle ( result ) return result
Collects a comma-separated set of hosts (host:port) and optionally
    randomize the returned list.