Accepts new clients and sends them to the to _handle_accepted within a subthread
766674
def _mainthread_accept_clients(self):
        
        try:
            if self._accept_selector.select(timeout=self.block_time):
                client = self._server_socket.accept()
                logging.info('Client connected: {}'.format(client[1]))

                self._threads_limiter.start_thread(target=self._subthread_handle_accepted,
                                                   args=(client,))
        except socket.error:
            pass
1098163
private void processNewlyAvailableInstances() {
		synchronized (globalLock) {
			Instance instance;

			while ((instance = newlyAvailableInstances.poll()) != null) {
				if (instance.hasResourcesAvailable()) {
					instancesWithAvailableResources.put(instance.getTaskManagerID(), instance);
				}
			}
		}
	}
278251
def process_request_thread(self, request, client_address):
        
        try:
            self.finish_request(request, client_address)
            self.shutdown_request(request)
        except:
            self.handle_error(request, client_address)
            self.shutdown_request(request)
1162633
def accept(self):
        
        if self._meta_runner:
            raise RuntimeError('payloads scheduled for %s before being started' % self)
        self._must_shutdown = False
        self._logger.info('%s starting', self.__class__.__name__)
        # force collecting objects so that defunct, migrated and overwritten services are destroyed now
        gc.collect()
        self._adopt_services()
        self.adopt(self._accept_services, flavour=trio)
        self._meta_runner.run()
177679
def join(self, timeout=None):
        
        self._server.join(timeout)
        if self._handler_thread:
            self._handler_thread.join(timeout)
721584
def _threaded(self, *args, **kwargs):
        """"""

        for target in self.targets:
            result = target(*args, **kwargs)
            self.queue.put(result)
920525
public static void registerBlockedThreadHandler(BlockedThreadHandler handler, Thread thread) {
		synchronized (blockedHandlers) {
			blockedHandlers.put(thread, handler);
		}
	}
722404
def _serve_clients(self):
        '''
        
        '''
        self.__up = True
        while self.__up:
            log.debug('Waiting for a client to connect')
            try:
                conn, addr = self.skt.accept()
                log.debug('Received connection from %s:%d', addr[0], addr[1])
            except socket.error as error:
                if not self.__up:
                    return
                msg = 'Received listener socket error: {}'.format(error)
                log.error(msg, exc_info=True)
                raise ListenerException(msg)
            client_thread = threading.Thread(target=self._client_connection, args=(conn, addr,))
            client_thread.start()
1092666
def process_request(self, request, client_address):
    
    t = threading.Thread(
      target=self.process_request_thread,
      args=(request, client_address),
      name="PailgunRequestThread",
    )
    t.daemon = self.daemon_threads
    t.start()
271000
async def addSignalHandlers(self):
        '''
        
        '''

        def sigterm():
            print('Caught SIGTERM, shutting down.')
            asyncio.create_task(self.fini())

        def sigint():
            print('Caught SIGINT, shutting down.')
            asyncio.create_task(self.fini())

        loop = asyncio.get_running_loop()
        loop.add_signal_handler(signal.SIGINT, sigint)
        loop.add_signal_handler(signal.SIGTERM, sigterm)
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
1216558
def _threaded_callback(callback, *args):
    
    t = Thread(target=callback, args=args)
    t.daemon = True
    t.start()
574494
def bind_client(self, new):
        """"""
        top = self._stack[-1]
        self._stack[-1] = (new, top[1])
973854
protected void handleClient(final Socket client) throws IOException {
		final ClientHandler handler = new ClientHandler(client);
		this.executorService.execute(handler);
	}
896805
public static void main(String[] args){

        // Listeners are subscribed by passing them to the #subscribe() method
        bus.subscribe(new ListenerDefinition.SyncAsyncListener());

        // #subscribe() is idem-potent => Multiple calls to subscribe do NOT add the listener more than once (set semantics)
        Object listener = new ListenerDefinition.SyncAsyncListener();
        bus.subscribe(listener);
        bus.subscribe(listener);

        // Classes without handlers will be silently ignored
        bus.subscribe(new Object());
        bus.subscribe(new String());

        bus.publishAsync(new File("/tmp/random.csv")); //returns immediately, publication will continue asynchronously
        bus.post(new File("/tmp/random.csv")).asynchronously(); // same as above

        bus.publish("some message");   // will return after each handler has been invoked
        bus.post("some message").now(); // same as above


    }
203279
def _send_to_others(self, message, channel):
        
        other_clients = [
            client for client in channel.clients
            if not client == self]
        for client in other_clients:
            client.send_queue.append(message)
643627
static void handleThrowable(Throwable t) {
        if (t instanceof ThreadDeath) {
            throw (ThreadDeath) t;
        }
        if (t instanceof VirtualMachineError) {
            throw (VirtualMachineError) t;
        }
        // All other instances of Throwable will be silently swallowed
    }