Use processes and Netmiko to connect to each of the devices. Execute
    'show version' on each device. Use a queue to pass the output back to the parent process.
    Record the amount of time required to do this.
199464
def main():
    
    start_time = datetime.now()
    output_q = Queue(maxsize=20)

    procs = []
    for a_device in devices:
        my_proc = Process(target=show_version_queue, args=(a_device, output_q))
        my_proc.start()
        procs.append(my_proc)

    # Make sure all processes have finished
    for a_proc in procs:
        a_proc.join()

    while not output_q.empty():
        my_dict = output_q.get()
        for k, val in my_dict.items():
            print(k)
            print(val)

    print("\nElapsed time: " + str(datetime.now() - start_time))
383255
def run(self):
        
        if self.json_output:
            output_to_pipe(self._pipe_in)  # Disable stdout
            error = self.lib.iperf_run_client(self._test)

            if not self.iperf_version.startswith('iperf 3.1'):
                data = read_pipe(self._pipe_out)
                if data.startswith('Control connection'):
                    data = '{' + data.split('{', 1)[1]
            else:
                data = c_char_p(
                    self.lib.iperf_get_test_json_output_string(self._test)
                ).value
                if data:
                    data = data.decode('utf-8')

            output_to_screen(self._stdout_fd, self._stderr_fd)  # enable stdout

            if not data or error:
                data = '{"error": "%s"}' % self._error_to_string(self._errno)

            return TestResult(data)
586649
def show(self, only_status=False, show_cluster=True):
        
        self.__update_status()
        indent = ''.join([" " for i in xrange(0, len(self.name) + 2)])
        print_("{}: {}".format(self.name, self.__get_status_string()))
        if not only_status:
            if show_cluster:
                print_("{}{}={}".format(indent, 'cluster', self.cluster.name))
            print_("{}{}={}".format(indent, 'auto_bootstrap', self.auto_bootstrap))
            if self.network_interfaces['thrift'] is not None:
                print_("{}{}={}".format(indent, 'thrift', self.network_interfaces['thrift']))
            if self.network_interfaces['binary'] is not None:
                print_("{}{}={}".format(indent, 'binary', self.network_interfaces['binary']))
            print_("{}{}={}".format(indent, 'storage', self.network_interfaces['storage']))
            print_("{}{}={}".format(indent, 'jmx_port', self.jmx_port))
            print_("{}{}={}".format(indent, 'remote_debug_port', self.remote_debug_port))
            print_("{}{}={}".format(indent, 'byteman_port', self.byteman_port))
            print_("{}{}={}".format(indent, 'initial_token', self.initial_token))
            if self.pid:
                print_("{}{}={}".format(indent, 'pid', self.pid))
771728
def init_process(self):
        
        self.device = Device.objects.filter(protocol__daq_daemon=1, active=1, id=self.device_id).first()
        if not self.device:
            logger.error("Error init_process for %s" % self.device_id)
            return False
        self.dt_set = min(self.dt_set, self.device.polling_interval)
        self.dt_query_data = self.device.polling_interval
        try:
            self.device = self.device.get_device_instance()
        except:
            var = traceback.format_exc()
            logger.error("exception while initialisation of DAQ Process for Device %d %s %s" % (
                self.device_id, linesep, var))

        return True
542616
def connect(self):
        
        jobs = []
        self._socket.connect((self.host, self.port))
        try:
            jobs = [spawn(self._recv_loop), spawn(self._send_loop)]
            joinall(jobs)
        finally:
            killall(jobs)
468732
def init_process(self):
        

        for item in Device.objects.filter(protocol__daq_daemon=1, active=1, id__in=self.device_ids):
            try:
                tmp_device = item.get_device_instance()
                if tmp_device is not None:
                    self.devices[item.pk] = tmp_device
                    self.dt_set = min(self.dt_set, item.polling_interval)
                    self.dt_query_data = min(self.dt_query_data, item.polling_interval)
            except:
                var = traceback.format_exc()
                logger.error("exception while initialisation of DAQ Process for Device %d %s %s" % (
                    item.pk, linesep, var))

        return True
901880
async def start(self):
        """"""

        self._command_task.start()

        try:
            await self._cleanup_old_connections()
        except Exception:
            await self.stop()
            raise

        #FIXME: This is a temporary hack, get the actual device we are serving.
        iotile_id = next(iter(self.adapter.devices))
        self.device = self.adapter.devices[iotile_id]

        self._logger.info("Serving device 0x%04X over BLED112", iotile_id)
        await self._update_advertisement()

        self.setup_client(self.CLIENT_ID, scan=False, broadcast=True)
956104
def init(opts):
    '''
    
    '''
    proxy_dict = opts.get('proxy', {})
    conn_args = proxy_dict.copy()
    conn_args.pop('proxytype', None)
    opts['multiprocessing'] = conn_args.get('multiprocessing', True)
    # This is not a SSH-based proxy, so it should be safe to enable
    # multiprocessing.
    try:
        conn = pyeapi.client.connect(**conn_args)
        node = pyeapi.client.Node(conn, enablepwd=conn_args.get('enablepwd'))
        pyeapi_device['connection'] = node
        pyeapi_device['initialized'] = True
        pyeapi_device['up'] = True
    except pyeapi.eapilib.ConnectionError as cerr:
        log.error('Unable to connect to %s', conn_args['host'], exc_info=True)
        return False
    return True
1297072
def processes(self, processes):
        '''
        '''

        if self._processes > 1:
            self._pool.close()
            self._pool.join()
            self._pool = multiprocessing.Pool(processes)
        else:
            self._pool = None
        self._logger.log('debug', 'Number of processes set to {}'.format(
            processes
        ))
97694
def main():
    
    parser = argparse.ArgumentParser(
        prog='',
        description='Dump data about Sonos services'
    )
    parser.add_argument(
        '-d', '--device',
        default=None,
        help="The ip address of the device to query. "
             "If none is supplied, a random device will be used"
    )
    parser.add_argument(
        '-s', '--service',
        default=None,
        help="Dump data relating to services matching this regexp "
             "only, e.g. %(prog)s -s GroupRenderingControl"
    )

    args = parser.parse_args()

    # get a zone player - any one will do
    if args.device:
        device = soco.SoCo(args.device)
    else:
        device = soco.discovery.any_soco()
    print("Querying %s" % device.player_name)
    # loop over each of the available services
    # pylint: disable=no-member
    services = (srv(device) for srv in soco.services.Service.__subclasses__())

    for srv in services:
        if args.service is None or re.search(
                args.service, srv.service_type):
            print_details(srv)
714310
def execute_with(host_list, options = {}, &block)
      host_list.each { |host| @connections[host] ||= LazyConnection.new(host, @net_ssh_options) }
      args = options[:args] || []
      num_threads = options[:num_threads] || DEFAULT_THREAD_POOL_SIZE
      if options[:serial]
        host_list.each { |host| @connections[host].self_eval args, &block }
      elsif options[:batch_by]
        num_threads = options[:batch_by] if num_threads == :unlimited
        host_list.each_slice(options[:batch_by]) do |batch|
          Weave.with_thread_pool(batch, num_threads) do |host, mutex|
            @connections[host].self_eval args, mutex, &block
          end
        end
      else
        num_threads = host_list.size if num_threads == :unlimited
        Weave.with_thread_pool(host_list, num_threads) do |host, mutex|
          @connections[host].self_eval args, mutex, &block
        end
      end
    end
600662
def main():
    
    start_time = datetime.now()

    for a_device in devices:
        my_thread = threading.Thread(target=show_version, args=(a_device,))
        my_thread.start()

    main_thread = threading.currentThread()
    for some_thread in threading.enumerate():
        if some_thread != main_thread:
            print(some_thread)
            some_thread.join()

    print("\nElapsed time: " + str(datetime.now() - start_time))
1096559
def start(bt_device=''):
        '''
        
        '''
        # import ptyprocess here so as long as all implementations are in the same file, all will work
        import ptyprocess

        if not bt_device:
            bt_device = 'hci0'

        log.info('Start receiving broadcasts (device %s)', bt_device)
        DEVNULL = subprocess.DEVNULL if sys.version_info >= (3, 3) else open(os.devnull, 'wb')

        subprocess.call('sudo hciconfig %s reset' % bt_device, shell=True, stdout=DEVNULL)
        hcitool = subprocess.Popen(['sudo', '-n', 'hcitool', 'lescan', '--duplicates'], stdout=DEVNULL)
        hcidump = ptyprocess.PtyProcess.spawn(['sudo', '-n', 'hcidump', '--raw'])
        return (hcitool, hcidump)
826275
def _run(self):
        
        port = broadcast_port
        nameservers = []
        if self._multicast_enabled:
            recv = MulticastReceiver(port).settimeout(2.)
            while True:
                try:
                    recv = MulticastReceiver(port).settimeout(2.)
                    LOGGER.info("Receiver initialized.")
                    break
                except IOError as err:
                    if err.errno == errno.ENODEV:
                        LOGGER.error("Receiver initialization failed "
                                     "(no such device). "
                                     "Trying again in %d s",
                                     10)
                        time.sleep(10)
                    else:
                        raise
        else:
            recv = _SimpleReceiver(port)
            nameservers = ["localhost"]

        self._is_running = True
        with Publish("address_receiver", self._port, ["addresses"],
                     nameservers=nameservers) as pub:
            try:
                while self._do_run:
                    try:
                        data, fromaddr = recv()
                        LOGGER.debug("data %s", data)
                        del fromaddr
                    except SocketTimeout:
                        if self._multicast_enabled:
                            LOGGER.debug("Multicast socket timed out on recv!")
                            continue
                    finally:
                        self._check_age(pub, min_interval=self._max_age / 20)
                        if self._do_heartbeat:
                            pub.heartbeat(min_interval=29)
                    msg = Message.decode(data)
                    name = msg.subject.split("/")[1]
                    if(msg.type == 'info' and
                       msg.subject.lower().startswith(self._subject)):
                        addr = msg.data["URI"]
                        msg.data['status'] = True
                        metadata = copy.copy(msg.data)
                        metadata["name"] = name

                        LOGGER.debug('receiving address %s %s %s', str(addr),
                                     str(name), str(metadata))
                        if addr not in self._addresses:
                            LOGGER.info("nameserver: publish add '%s'",
                                        str(msg))
                            pub.send(msg.encode())
                        self._add(addr, metadata)
            finally:
                self._is_running = False
                recv.close()
540812
def process_npdu(self, npdu):
        """"""
        if _debug: DeviceToDeviceClientService._debug("process_npdu %r", npdu)

        # broadcast messages go to everyone
        if npdu.pduDestination.addrType == Address.localBroadcastAddr:
            destList = self.connections.keys()
        else:
            conn = self.connections.get(npdu.pduDestination, None)
            if not conn:
                if _debug: DeviceToDeviceClientService._debug("    - not a connected client")

                # start a connection attempt
                conn = self.connect(npdu.pduDestination)
            if not conn.connected:
                # keep a reference to this npdu to send after the ack comes back
                conn.pendingNPDU.append(npdu)
                return

            destList = [npdu.pduDestination]
        if _debug: DeviceToDeviceClientService._debug("    - destList: %r", destList)

        for dest in destList:
            # make device-to-device APDU
            xpdu = DeviceToDeviceAPDU(npdu)
            xpdu.pduDestination = dest

            # send it down to the multiplexer
            self.service_request(xpdu)
1092139
def connect(self, addr):
        """"""
        if _debug: DeviceToDeviceClientService._debug("connect %r", addr)

        # make a connection
        conn = ConnectionState(addr)
        self.multiplexer.connections[addr] = conn

        # associate with this service, but it is not connected until the ack comes back
        conn.service = self

        # keep a list of pending NPDU objects until the ack comes back
        conn.pendingNPDU = []

        # build a service request
        request = ServiceRequest(DEVICE_TO_DEVICE_SERVICE_ID)
        request.pduDestination = addr

        # send it
        self.service_request(request)

        # return the connection object
        return conn
1165609
function () {
			winble.deviceManager.connectionWatcher = Windows.Devices.Enumeration.Pnp.PnpObject.createWatcher(
				Windows.Devices.Enumeration.Pnp.PnpObjectType.deviceContainer,
				["System.Devices.Connected"],
				"");
			winble.deviceManager.connectionWatcher.onupdated = winble.deviceManager.onDeviceConnectionUpdated;
			winble.deviceManager.connectionWatcher.start();
		}