Temporarily retarget the client for one call.  This is useful
        when having to deal with a subset of hosts for one call.
344837
def target(self, hosts):
        
        if self.__is_retargeted:
            raise TypeError('Cannot use target more than once.')
        rv = FanoutClient(hosts, connection_pool=self.connection_pool,
                          max_concurrency=self._max_concurrency)
        rv._cb_poll = self._cb_poll
        rv.__is_retargeted = True
        return rv
395205
function once (callback, context) {
  var done = false
  var rest = null
  var args = arraySlice(arguments, 2)
  context = context || this
  return function () {
    if (done) {
      return rest
    }
    rest = callback.apply(context, arraySlice(arguments).concat(args))
    done = true
    return rest
  }
}
283995
function reapply (parameters) {
  return (arguments.length > 1)
  ? reapplyer(parameters, arguments[1])
  : reapplyer.bind(null, parameters)
}
287467
public void cancel1xxTimer() {
		if (proxy1xxTimeoutTask != null && proxyBranch1xxTimerStarted) {
			proxy1xxTimeoutTask.cancel();
			proxy1xxTimeoutTask = null;
			proxyBranch1xxTimerStarted = false;
		}
	}
635357
def stop_tracking_host(self):
        '''
            
        '''
        try:
            self.server.hosts.remove(self.client_address[0])
            if hasattr(self.server.module, 'on_shutdown'):
                self.server.module.on_shutdown(self.server.context, self.server.connection)
        except ValueError:
            pass
1309871
def remove_client(self, client_identifier):
        """"""
        new_clients = self.clients
        new_clients.remove(client_identifier)
        yield from self._server.group_clients(self.identifier, new_clients)
        _LOGGER.info('removed %s from %s', client_identifier, self.identifier)
        self._server.client(client_identifier).callback()
        self.callback()
10061
@SuppressWarnings("deprecation")
    private void cancelRequestAndWorkerOnHost(List<String> targetHosts) {

        List<String> validTargetHosts = new ArrayList<String>(workers.keySet());
        validTargetHosts.retainAll(targetHosts);
        logger.info("targetHosts for cancel: Total: {}"
                + " Valid in current manager with worker threads: {}",
                targetHosts.size(), validTargetHosts.size());

        for (String targetHost : validTargetHosts) {

            ActorRef worker = workers.get(targetHost);

            if (worker != null && !worker.isTerminated()) {
                worker.tell(OperationWorkerMsgType.CANCEL, getSelf());
                logger.info("Submitted CANCEL request on Host {}", targetHost);
            } else {
                logger.info(
                        "Did NOT Submitted "
                                + "CANCEL request on Host {} as worker on this host is null or already killed",
                        targetHost);
            }

        }

    }
169610
public final void destroyRemotely() {
        ClientMessage clientMessage = ClientDestroyProxyCodec.encodeRequest(getDistributedObjectName(), getServiceName());
        try {
            new ClientInvocation(getClient(), clientMessage, getName()).invoke().get();
        } catch (Exception e) {
            throw rethrow(e);
        }
    }
970500
def call_openers(self, client, clients_list):
        
        for func in self.openers:
            func(client, clients_list)
1343565
def reinitialize():
    
    from ozelot import client

    # import all additional models needed in this project
    # noinspection PyUnresolvedReferences
    from ozelot.orm.target import ORMTargetMarker

    client = client.get_client()
    base.Base.drop_all(client)
    base.Base.create_all(client)
991905
def start(self, hostname=None, port=None):
        
        if hostname is None:
            hostname = settings.settings['mx_host']
        if port is None:
            port = settings.settings['mx_port']

        reloader = False        # use_reloader: the default setting for the reloader.
        debugger = False        #
        evalex = True           # should the exception evaluation feature be enabled?
        threaded = False        # True if each request is handled in a separate thread
        processes = 1           # if greater than 1 then handle each request in a new process
        reloader_interval = 1   # the interval for the reloader in seconds.
        static_files = None     # static_files: optional dict of static files.
        extra_files = None      # extra_files: optional list of extra files to track for reloading.
        ssl_context = None      # ssl_context: optional SSL context for running server in HTTPS mode.

        self.mx_thread = Thread(target=run_simple(hostname=hostname,
                                                  port=port,
                                                  application=self,
                                                  use_debugger=debugger,
                                                  use_evalex=evalex,
                                                  extra_files=extra_files,
                                                  use_reloader=reloader,
                                                  reloader_interval=reloader_interval,
                                                  threaded=threaded,
                                                  processes=processes,
                                                  static_files=static_files,
                                                  ssl_context=ssl_context))
        self.mx_thread.daemon = True
        self.mx_thread.start()
482531
public void activate(InetAddress host, int port, Collection<String> nonProxyHosts) {
        for (String scheme : new String[] {"http", "https"}) {
            String currentProxyHost = System.getProperty(scheme + ".proxyHost");
            String currentProxyPort = System.getProperty(scheme + ".proxyPort");
            if (currentProxyHost != null) {
                originalProxies.put(scheme, new InetSocketAddress(currentProxyHost, Integer.parseInt(currentProxyPort)));
            }
            System.setProperty(scheme + ".proxyHost", new InetSocketAddress(host, port).getHostString());
            System.setProperty(scheme + ".proxyPort", Integer.toString(port));
        }

        String currentNonProxyHosts = System.getProperty("http.nonProxyHosts");
        if (currentNonProxyHosts == null) {
            originalNonProxyHosts.clear();
        } else {
            for (String nonProxyHost : Splitter.on('|').split(currentNonProxyHosts)) {
                originalNonProxyHosts.add(nonProxyHost);
            }
        }
        System.setProperty("http.nonProxyHosts", Joiner.on('|').join(nonProxyHosts));
    }
1106442
private void resetClients( boolean shutdown ) {

		// Only agent clients need to be reconfigured.
		// Make fresh snapshots of the CLIENTS, as we don't want to reconfigure them while holding the lock.
		final List<HttpAgentClient> clients;
		synchronized( this ) {

			// Get the snapshot.
			clients = new ArrayList<>( this.agentClients );

			// Remove the clients, new ones will be created if necessary.
			this.agentClients.clear();
		}

		// Now reconfigure all the CLIENTS.
		for( HttpAgentClient client : clients ) {
			try {
				final ReconfigurableClient<?> reconfigurable = client.getReconfigurableClient();
				if (shutdown)
					reconfigurable.closeConnection();
				else
					reconfigurable.switchMessagingType( HttpConstants.FACTORY_HTTP );

			} catch( Throwable t ) {
				// Warn but continue to reconfigure the next CLIENTS!
				this.logger.warning( "A client has thrown an exception on reconfiguration: " + client );
				Utils.logException( this.logger, new RuntimeException( t ));
			}
		}
	}
1245412
def callRemote(self, *a, **kw):
        
        if not self.running:
            return defer.fail(ServiceStopped())
        return self.clientFactory.callRemote(*a, **kw)
662989
@Override
    public List<String> setTargetHostsFromList(List<String> targetHosts) {

        List<String> targetHostsNew = new ArrayList<String>();
        targetHostsNew.addAll(targetHosts);
        int dupSize = PcTargetHostsUtils.removeDuplicateNodeList(targetHostsNew);
        if (dupSize > 0) {
            logger.info("get target hosts with duplicated hosts of " + dupSize
                    + " with new total size of " + targetHosts.size());
        }
        return targetHostsNew;
    }
1342929
@SuppressWarnings("deprecation")
    public boolean cancelOnTargetHosts(List<String> targetHosts) {

        boolean success = false;

        try {

            switch (state) {

            case IN_PROGRESS:
                if (executionManager != null
                        && !executionManager.isTerminated()) {
                    executionManager.tell(new CancelTaskOnHostRequest(
                            targetHosts), executionManager);
                    logger.info(
                            "asked task to stop from running on target hosts with count {}...",
                            targetHosts.size());
                } else {
                    logger.info("manager already killed or not exist.. NO OP");
                }
                success = true;
                break;
            case COMPLETED_WITHOUT_ERROR:
            case COMPLETED_WITH_ERROR:
            case WAITING:
                logger.info("will NO OP for cancelOnTargetHost as it is not in IN_PROGRESS state");
                success = true;
                break;
            default:
                break;

            }

        } catch (Exception e) {
            logger.error(
                    "cancel task {} on hosts with count {} error with exception details ",
                    this.getTaskId(), targetHosts.size(), e);
        }

        return success;
    }
721489
def on_down(self, host):
        
        future = self.remove_pool(host)
        if future:
            future.add_done_callback(lambda f: self.update_created_pools())