Main loop listening for incoming data.
359450
def __receiver_loop(self):
        
        log.info("Starting receiver loop")
        notify_disconnected = True
        try:
            while self.running:
                try:
                    while self.running:
                        frames = self.__read()

                        for frame in frames:
                            f = utils.parse_frame(frame)
                            if f is None:
                                continue
                            if self.__auto_decode:
                                f.body = decode(f.body)
                            self.process_frame(f, frame)
                except exception.ConnectionClosedException:
                    if self.running:
                        #
                        # Clear out any half-received messages after losing connection
                        #
                        self.__recvbuf = b''
                        self.running = False
                        notify_disconnected = True
                    break
                finally:
                    self.cleanup()
        finally:
            with self.__receiver_thread_exit_condition:
                self.__receiver_thread_exited = True
                self.__receiver_thread_exit_condition.notifyAll()
            log.info("Receiver loop ended")
            self.notify('receiver_loop_completed')
            if notify_disconnected:
                self.notify('disconnected')
            with self.__connect_wait_condition:
                self.__connect_wait_condition.notifyAll()
960210
public void run() {
        int length;
        char cs[] = new char[256];
        int ioErrorCount = 0;
        Reader reader = pair.getReader();

        logger.trace("Starting primary loop");
        while ( !stopRequested && !foundEOF && ioErrorCount < 4) {
            try {
                logger.trace("Checking ready");
                boolean ready = false;
                try {
                    ready = reader.ready(); // will not block
                    if( reader.markSupported() ) logger.trace("Mark Supported");
                } catch(Exception ioe) {
                    // The Pipe most likely closed on us.
                    logger.debug("Exception in PollingConsumer: " + ioe);
                    foundEOF = true;
                    break;
                }

                //if( !ready ) { ready = true; log.fine("Faking ready"); }

                if ( ready ) {
                    logger.trace("Is Ready");


                    // don't modify the buffer while processing is happening
                    // written as while loop to prevent spurious interrupts
                    synchronized(this) {
                        while( callerProcessing.booleanValue() ) {
                            logger.trace("Waiting for caller to finish");
                            try {
                                wait();
                            } catch(InterruptedException ie) {
                                logger.trace("Woken up early");
                                continue;
                            }
                        }

                        logger.trace("About to wait for buffer lock");
                        synchronized(buffer) {
                            length = reader.read(cs);

                            if( length == -1 ) { //EOF
                                logger.trace("Found the EOF");
                                logger.trace("Current buffer: " + buffer.toString() );
                                foundEOF = true;
                                dirtyBuffer = true;
                                break;
                            }

                            String print = new String(cs, 0, length);
                            print = print.replaceAll("\n", "\\\\n");
                            print = print.replaceAll("\r", "\\\\r");
                            logger.trace("Appending >>>" + print + "<<<");
                            buffer.append( cs, 0, length ); // thread safe

                            logger.trace("Current Buffer: " + buffer.toString() );
                            dirtyBuffer = true;

                            /**
                             * TODO Trim down buffer.  This current method won't work if a resume comes in, since it's offset
                             * will be invalid once this delete method runs
                             *
                             * // since we only added one char, we should only have to remove one
                             * if( buffer.length() > BUFFERMAX )
                             * buffer.delete(0, BUFFERMAX - buffer.length() );
                             */

                            logger.trace("Waking up who ever if listening");
                            buffer.notify(); // seeing that we read something, wait people up

                            // We explicitly call this after appending to the
                            // buffer, just in case one of the BufferChangeLoggers
                            // accidentally modifies the character buffer.
                            notifyBufferChange(cs, length);
                        }
                    }

                } else {
                    logger.trace("Not Ready, sleeping");
                    try { Thread.sleep(500); } catch(InterruptedException ie) { }
                    logger.trace("Done sleeping");
                    //continue;
                }
            }catch(IOException ioe) {
                logger.warn("Exception in loop body: " + ioe);
                ioErrorCount++;
                //continue;
            }
        } // end while loop


        synchronized(buffer) {
            buffer.notify();
        }
        if( stopRequested ) {
            logger.debug("Stop Requested");
            pair.close();
        }
        if ( foundEOF )
            logger.debug("Found EOF to stop while loop");
        if( ioErrorCount >= 4 )
            logger.debug("ioErrorCount at " + ioErrorCount );
        logger.trace("Leaving primary loop");
    }
228794
def run(self):
        """"""
        self.signal_init()
        self.listen_init()
        self.logger.info('starting')
        self.loop.start()
1277099
def feed(self, data):
        """"""
        self._buffers.append(data)
        self._buffer_size += len(data)
        self._maybe_pause_transport()
        self._can_read.set()
1033179
def listener(self):
        """"""
        while 1:
            try:
                data = self.read_eager()
            except EOFError:
                print('*** Connection closed by remote host ***')
                return
            if data:
                self.stdout.write(data)
            else:
                self.stdout.flush()
1358237
def _heartbeat_loop(self):
        """"""
        self.logger.debug("running main heartbeat thread")
        while not self.closed:
            time.sleep(self.settings['SLEEP_TIME'])
            self._report_self()
513417
def mainloop(self):
        """"""
        try:
            while (not self.ev_quit.is_set()):
                try:
                    self.handle_request()

                except socketTimeout:
                    continue
        finally:
            self.socket.close()
975009
def pipe_data_received(self, fd, data):
        """"""
        if fd == 2:  # stderr fd number
            self._on_stderr(data)
        elif self._on_data:
            self._on_data(data)
        else:
            self._queued_data.append(data)
416488
def listen(self, callback=None, timeout=(5, 300)):
        """"""
        if self._running:
            return False
        # if self.devices() is False:
        #    return False
        self._queue = Queue()
        self._running = True
        self._timeout = timeout
        self._callback_listen = callback
        threading.Thread(target=self._thread_listen, args=()).start()
        threading.Thread(target=self._thread_worker, args=()).start()
        return True
601727
def listen(self):
        
        with Consumer(self.connection, queues=self.queue, on_message=self.on_message,
                      auto_declare=False):
            for _ in eventloop(self.connection, timeout=1, ignore_timeouts=True):
                    pass
445266
def _start_loop(self):
        """"""
        # Create our main loop, get our bus, and add the signal handler
        loop = GObject.MainLoop()
        bus = SystemBus()
        manager = bus.get(".NetworkManager")
        manager.onPropertiesChanged = self._vpn_signal_handler

        # Loop forever
        loop.run()
1276787
def run(self):
        """"""
        while self.keep_listening:
            for interface in self.node.interfaces:
                try:
                    self.recv(self.node.inq[interface].get(timeout=0), interface)
                except Empty:
                    sleep(0.01)
806784
def main(self, *args, **kwargs):
        """"""
        self.start(*args, **kwargs)
        try:
            while 1:
                body, message = yield self.receive()
                handler = self.get_handler(message)
                handler(body, message)
        finally:
            self.stop(*args, **kwargs)
360828
def main(url):
    """"""
    try:
        listener = ListenerWorker(url)
        listener.connect()
        listener.run_forever()
    except KeyboardInterrupt:
        listener.close()
734220
def dataReceived(self, data):
        
        self.stompBuffer.appendData(data)

        while True:
           msg = self.stompBuffer.getOneMessage()
           if msg is None:
               break

           returned = self.react(msg)
           if returned:
               self.transport.write(returned)
234395
def main_loop_iteration(timeout=None):
    """"""
    prev_nr_read = nr_handle_read
    asyncore.loop(count=1, timeout=timeout, use_poll=True)
    return nr_handle_read - prev_nr_read
922139
def dataReceived(self, data):
        
        self.connection._iobuf.write(data)
        self.connection.handle_read()