Accept a new connection and put it on the Queue.
169164
def tick(self):
        """"""
        try:
            s, addr = self.socket.accept()
            if not self.ready:
                return
            
            prevent_socket_inheritance(s)
            if hasattr(s, 'settimeout'):
                s.settimeout(self.timeout)
            
            makefile = CP_fileobject
            ssl_env = {}
            # if ssl cert and key are set, we try to be a secure HTTP server
            if self.ssl_adapter is not None:
                try:
                    s, ssl_env = self.ssl_adapter.wrap(s)
                except NoSSLError:
                    msg = ("The client sent a plain HTTP request, but "
                           "this server only speaks HTTPS on this port.")
                    buf = ["%s 400 Bad Request\r\n" % self.protocol,
                           "Content-Length: %s\r\n" % len(msg),
                           "Content-Type: text/plain\r\n\r\n",
                           msg]
                    
                    wfile = CP_fileobject(s, "wb", DEFAULT_BUFFER_SIZE)
                    try:
                        wfile.sendall("".join(buf))
                    except socket.error, x:
                        if x.args[0] not in socket_errors_to_ignore:
                            raise
                    return
                if not s:
                    return
                makefile = self.ssl_adapter.makefile
                # Re-apply our timeout since we may have a new socket object
                if hasattr(s, 'settimeout'):
                    s.settimeout(self.timeout)
            
            conn = self.ConnectionClass(self, s, makefile)
            
            if not isinstance(self.bind_addr, basestring):
                # optional values
                # Until we do DNS lookups, omit REMOTE_HOST
                if addr is None: # sometimes this can happen
                    # figure out if AF_INET or AF_INET6.
                    if len(s.getsockname()) == 2:
                        # AF_INET
                        addr = ('0.0.0.0', 0)
                    else:
                        # AF_INET6
                        addr = ('::', 0)
                conn.remote_addr = addr[0]
                conn.remote_port = addr[1]
            
            conn.ssl_env = ssl_env
            
            self.requests.put(conn)
        except socket.timeout:
            # The only reason for the timeout in start() is so we can
            # notice keyboard interrupts on Win32, which don't interrupt
            # accept() by default
            return
        except socket.error, x:
            if x.args[0] in socket_error_eintr:
                # I *think* this is right. EINTR should occur when a signal
                # is received during the accept() call; all docs say retry
                # the call, and I *think* I'm reading it right that Python
                # will then go ahead and poll for and handle the signal
                # elsewhere. See http://www.cherrypy.org/ticket/707.
                return
            if x.args[0] in socket_errors_nonblocking:
                # Just try again. See http://www.cherrypy.org/ticket/479.
                return
            if x.args[0] in socket_errors_to_ignore:
                # Our socket was closed.
                # See http://www.cherrypy.org/ticket/686.
                return
            raise
833284
def create_queue(self, *args, **kwargs):
        """"""
        q = queue.Queue(*args, **kwargs)
        q.Empty = queue.Empty
        return q
374492
def add_new(self, command):
        """"""
        self.queue[self.next_key] = command
        self.queue[self.next_key]['status'] = 'queued'
        self.queue[self.next_key]['returncode'] = ''
        self.queue[self.next_key]['stdout'] = ''
        self.queue[self.next_key]['stderr'] = ''
        self.queue[self.next_key]['start'] = ''
        self.queue[self.next_key]['end'] = ''

        self.next_key += 1
        self.write()
487536
def add(self, connection):
        ''''''
        key = (connection.host, connection.port)
        with self._lock:
            if key not in self._connections:
                self._connections[key] = connection
                self.added(connection)
                return connection
            else:
                return None
343053
def _new_conn(self):
        
        self.num_connections += 1
        log.info("Starting new HTTP connection (%d): %s" %
                 (self.num_connections, self.host))
        return HTTPConnection(host=self.host, port=self.port)
69838
def __start_connection(self, context, node, ccallbacks=None):
        """"""

        _logger.debug("Creating connection object: CONTEXT=[%s] NODE=[%s]", 
                      context, node)

        c = nsq.connection.Connection(
                context,
                node, 
                self.__identify, 
                self.__message_handler,
                self.__quit_ev,
                ccallbacks,
                ignore_quit=self.__connection_ignore_quit)

        g = gevent.spawn(c.run)

        # Now, wait for the thread to finish the connection.

        timeout_s = nsq.config.client.NEW_CONNECTION_NEGOTIATE_TIMEOUT_S
        if c.connected_ev.wait(timeout_s) is False:
            _logger.error("New connection to server [%s] timed-out. Cleaning-"
                          "up thread.", node)

            g.kill()
            g.join()

            # We'll try again on the next audit.

            raise EnvironmentError("Connection to server [%s] failed." % 
                                   (node,))

        self.__connections.append((node, c, g))
1038025
def new_connection(self):
        """"""
        if not self.prepared: self.prepare()
        con = sqlite3.connect(self.path, isolation_level=self.isolation)
        con.row_factory = self.factory
        if self.text_fact: con.text_factory = self.text_fact
        return con
59692
protected void setupQueue() throws IOException {
		if (queueName != null) {
			channel.queueDeclare(queueName, false, false, false, null);
		}
	}
901771
def queue(name = '', opts = {})
      queue = @connection.find_queue(name) || Queue.new(self, name, opts)
      @connection.register_queue queue
    end
971330
def up(queue, host=None):
    ''''''
    down_path = fsq_path.down(queue, host=host)
    _queue_ok(os.path.dirname(down_path))
    try:
        os.unlink(down_path)
    except (OSError, IOError, ), e:
        if e.errno != errno.ENOENT:
            raise FSQConfigError(e.errno, wrap_io_os_err(e))
1235845
def new_conn(self):
        
        """
        :return:
        """
        logger.debug("Opening new connection to rethinkdb with args=%s" % self._conn_args)
        return ConnectionWrapper(self._pool, **self._conn_args)
474678
def register_outgoing_conn(self, conn):
        """"""
        assert conn, "conn is required"
        conn.set_outbound_pending_change_callback(self._on_conn_change)
        self.connections.append(conn)
        self._set_on_close_cb(conn)
        self._on_conn_change()
933938
def on_connect(client):
    
    print "++ Opened connection to %s" % client.addrport()
    broadcast('%s joins the conversation.\n' % client.addrport() )
    CLIENT_LIST.append(client)
    client.send("Welcome to the Chat Server, %s.\n" % client.addrport() )
1302156
def send(self, message):
        """"""
        if not self.connected:
            raise TransportError('Not connected to NETCONF server')
        self.logger.debug('queueing %s', message)
        self._q.put(message)
923033
def put(self, item, block=True, timeout=None):
        """"""
        return self._queue.put(item, block, timeout)
348100
def work():
    """"""
    with rq.Connection(create_connection()):
        worker = rq.Worker(list(map(rq.Queue, listen)))
        worker.work()
416792
def connectionMade(self):
        
        self._buffer = b''
        self._queue = {}
        self._stopped = None
        self._tag = 0