load the hosts into a Queue for thread safety
511937
def configure_hosts!(hosts)
      @hosts_queue = Queue.new
      Array(hosts).each do |host|
        @hosts_queue.push(host)
      end
    end
1367704
def slave_for(self, service):
        """"""
        # TODO: make it coroutine and connect minsize connections
        if service not in self._slaves:
            self._slaves[service] = ManagedPool(
                self, service, is_master=False,
                db=self._redis_db,
                password=self._redis_password,
                encoding=self._redis_encoding,
                minsize=self._redis_minsize,
                maxsize=self._redis_maxsize,
                ssl=self._redis_ssl,
                parser=self._parser_class,
                loop=self._loop)
        return self._slaves[service]
195182
function () {
            var i, len;
            for (i = 0, len = layoutState.visiblePages.length; i < len; ++i) {
                this.queuePageToLoad(layoutState.visiblePages[i] - 1);
            }
        }
222164
def _ensure_queue(self):
        """"""
        if self._queue_path not in self._client.kv:
            self._client.kv[self._queue_path] = None
1030177
private String chooseHost(String[] dbHosts) {
        String host = null;
        synchronized (m_lastHostLock) {
            if (dbHosts.length == 1) {
                host = dbHosts[0];
            } else if (!Utils.isEmpty(m_lastHost)) {
                for (int index = 0; host == null && index < dbHosts.length; index++) {
                    if (dbHosts[index].equals(m_lastHost)) {
                        host = dbHosts[(++index) % dbHosts.length];
                    }
                }
            }
            if (host == null) {
                host = dbHosts[new Random().nextInt(dbHosts.length)];
            }
            m_lastHost = host;
        }
        return host;
    }
410294
function runQueue(){
			if( urllist.length ){
				AI.makeReq( o.proxy + urllist.join( "," ), elQueue );
				elQueue = $();
				urllist = [];
			}
		}
935039
def async_do(self, size=10):
        
        if hasattr(self._session, '_async_jobs'):
            logging.info("Executing asynchronous %s jobs found in queue by using %s threads..." % (
                len(self._session._async_jobs), size))
            threaded_requests.map(self._session._async_jobs, size=size)
213259
def serve(self):
        """"""
        while self.ready:
            try:
                self.tick()
            except (KeyboardInterrupt, SystemExit):
                raise
            except Exception:
                self.error_log(
                    'Error in HTTPServer.tick', level=logging.ERROR,
                    traceback=True,
                )

            if self.interrupt:
                while self.interrupt is True:
                    # Wait for self.stop() to complete. See _set_interrupt.
                    time.sleep(0.1)
                if self.interrupt:
                    raise self.interrupt
44394
private void initQueues()
  {
    LOGGER.debug("Init Queues");
    if (_active.getAndSet(true))
    {
      // NOP if the loader is already active
      return;
    }
    // start PUT and PROCESS queues
    _queuePut = new ArrayBlockingQueue<>(48);
    _queueProcess = new ArrayBlockingQueue<>(48);
    _put = new PutQueue(this);
    _process = new ProcessQueue(this);

    // Start queue. NOTE: This is not actively used
    _queueData = new ArrayBlockingQueue<>(1024);
    _thread = new Thread(this);
    _thread.setName("StreamLoaderThread");
    _thread.start();

    // Create stage
    _stage = new BufferStage(this, _op, _csvFileBucketSize, _csvFileSize);
  }
146712
def load(self):
        """"""
        # Init the static server list (if defined)
        self.static_server = GlancesStaticServer(config=self.config)

        # Init the password list (if defined)
        self.password = GlancesPassword(config=self.config)
269936
function queueHostBindingForCheck(dirIndex) {
    // Must subtract the header offset because hostBindings functions are generated with
    // instructions that expect element indices that are NOT adjusted (e.g. elementProperty).
    ngDevMode &&
        assertEqual(firstTemplatePass, true, 'Should only be called in first template pass.');
    (tView.hostBindings || (tView.hostBindings = [])).push(dirIndex, viewData.length - 1 - HEADER_OFFSET);
}
751047
def put_http_connection(self, host, is_secure, conn):
        
        with self.mutex:
            key = (host, is_secure)
            if key not in self.host_to_pool:
                self.host_to_pool[key] = HostConnectionPool()
            self.host_to_pool[key].put(conn)
489951
def getHosts(filename=None, hostlist=None):
    """"""
    if filename:
        return getHostsFromFile(filename)
    elif hostlist:
        return getHostsFromList(hostlist)
    elif getEnv() == "SLURM":
        return getHostsFromSLURM()
    elif getEnv() == "PBS":
        return getHostsFromPBS()
    elif getEnv() == "SGE":
        return getHostsFromSGE()
    else:
        return getDefaultHosts()
773585
def serve(application, host='127.0.0.1', port=8080, threads=4, **kw):
	
	
	# Bind and start the server; this is a blocking process.
	serve_(application, host=host, port=int(port), threads=int(threads), **kw)
1017202
public void initWithHosts(Map<Host, HostConnectionPool<CL>> hPools) {

		// Get the list of tokens for these hosts
		//tokenSupplier.initWithHosts(hPools.keySet());
		List<HostToken> allHostTokens = tokenSupplier.getTokens(hPools.keySet());
		Map<HostToken, HostConnectionPool<CL>> tokenPoolMap = new HashMap<HostToken, HostConnectionPool<CL>>();
	        
		// Update inner state with the host tokens.
		for (HostToken hToken : allHostTokens) {
			hostTokens.put(hToken.getHost(), hToken);
			tokenPoolMap.put(hToken, hPools.get(hToken.getHost()));
		}

		// Initialize Local selector
		Map<HostToken, HostConnectionPool<CL>> localPools = getHostPoolsForRack(tokenPoolMap, localRack);
		localSelector.initWithHosts(localPools);
		if (localSelector.isTokenAware() && localRack != null) {
		   replicationFactor.set(calculateReplicationFactor(allHostTokens));
		}

		// Initialize Remote selectors
		Set<String> remoteRacks = new HashSet<String>();
		for (Host host : hPools.keySet()) {
			String rack = host.getRack();
			if (localRack != null && !localRack.isEmpty() && rack != null && !rack.isEmpty() && !localRack.equals(rack)) {
				remoteRacks.add(rack);
			}
		}

		for (String rack : remoteRacks) {
			Map<HostToken, HostConnectionPool<CL>> dcPools = getHostPoolsForRack(tokenPoolMap, rack);
			HostSelectionStrategy<CL> remoteSelector = selectorFactory.vendPoolSelectionStrategy();
			remoteSelector.initWithHosts(dcPools);
			remoteRackSelectors.put(rack, remoteSelector);
		}

		remoteDCNames.swapWithList(remoteRackSelectors.keySet());

        topology.set(createTokenPoolTopology(allHostTokens));
	}
1131059
def host_threads=(threads)
      host_threads = REXML::XPath.first(@xml, 'ScanTemplate/General/hostThreads')
      host_threads.text = threads.to_s
    end
958142
def save_load(jid, load, minions=None):
    '''
    
    '''
    serv = _get_serv(ret=None)
    serv.set(jid, salt.utils.json.dumps(load))
    _append_list(serv, 'jids', jid)