The main loop. Poll sockets for I/O and run any other functions
        that need to be run every loop.
163700
def _loop(self, map):
        
        try:
            from asyncore import poll
        except ImportError:
            raise Exception("Couldn't find poll function. Cannot start bot.")
    
        while map:
            self.before_poll()
            poll(timeout=30.0, map=map)
            self.after_poll()
926609
def run(self):
        
        while True:
            self._logger.debug('Accepting connection')
            conn, addr = self._sock.accept()
            self._talk = SocketTalk(conn, encode=self._encode)

            self._logger.debug('Receiving action')
            action = self._receive()

            if self._on_action:
                self._on_action(action)

            key = None
            if action in ('set', 'get', 'del',):
                self._logger.debug('Receiving key')
                key = self._receive()

            value = None
            if action in ('set',):
                self._logger.debug('Receiving value')
                value = self._receive()

            # Process the request.
            if action == 'stop':
                self._send('ok')

            elif action == 'set':
                self._data[key] = value
                self._send('ok')

            elif action == 'get':
                try:
                    value = self._data[key]
                except:
                    self._logger.debug('Sending "key not found"')
                    self._send('key not found')
                else:
                    self._logger.debug('Sending "ok"')
                    self._send('ok')
                    self._logger.debug('Sending value')
                    self._send(value)

            elif action == 'del':
                try:
                    del self._data[key]
                except:
                    self._logger.debug('Sending "key not found"')
                    self._send('key not found')
                else:
                    self._logger.debug('Sending "ok"')
                    self._send('ok')

            elif action == 'size':
                self._send('ok')
                self._send(str(len(self._data)))

            elif action == 'keys':
                pickled = pickle.dumps(self._data.keys())
                self._send('ok')
                self._send(pickled)

            else:
                self._send('unknown action %s' % action)

            self._logger.debug('Closing')
            try:
                conn.shutdown(socket.SHUT_RDWR)
            except:
                self._logger.error('Failed to shutdown')
            conn.close()

            if action == 'stop':
                break

        self._logger.debug('Stopped')
570288
public void run() {
        this.running = true;

        while (this.running) {
            DatagramPacket packet = new DatagramPacket(this.buf, this.buf.length);
            try {
                this.socket.receive(packet);
            } catch (IOException ignored) {
                continue;
            }

            byte[] worker = new byte[2];
            System.arraycopy(this.buf, 2, worker, 0, 2);
            int length = (int)ByteArray.fromBytes(worker);
            worker = new byte[length];
            System.arraycopy(this.buf, 0, worker, 0, length);
            Command msg = new Command(worker, tk);
            InetAddress address = packet.getAddress();
            int port = packet.getPort();
            int timeStamp = (int)(System.currentTimeMillis() / 1000L);
            Response resp;
            if (msg.isHello()){
                resp = new Response(this.tk, this.deviceId, timeStamp);
            } else {
                if (msg.getDeviceID() != this.deviceId) continue;
                Object data = executeCommand(msg.getMethod(),msg.getParams());
                if (data == null){
                    data = "unknown_method";
                }
                resp = new Response(this.tk, this.deviceId, timeStamp, msg.getPayloadID(), data);
            }
            byte[] respMsg = resp.create();
            System.arraycopy(respMsg,0,this.buf,0,respMsg.length);
            packet = new DatagramPacket(buf, respMsg.length, address, port);

            try {
                this.socket.send(packet);
            } catch (IOException ignored) {
            }
        }
        this.socket.close();
    }
267010
def run(entry_point, drivers, loop = None):
    ''' 
    '''
    program = setup(entry_point, drivers)
    dispose = program.run()
    if loop == None:
        loop = asyncio.get_event_loop()

    loop.run_forever()
    dispose()
1064066
def run(self):
        
        self._stop = False # Allow re-starting the event loop
        while not self._stop:
            try:
                self._buffer += self.socket.recv(4096)
            except socket.error:
                raise

            lines = self._buffer.split("\n")
            self._buffer = lines.pop() # Last line may not have been fully read
            for line in lines:
                line = line.rstrip("\r")
                _log.debug("%s --> %s", self.server.host, line)
                self.dispatch_event("LINE", line)
                self.dispatch_event("ACTIVITY")
801498
private void loop(final ServerSocket server) throws IOException {
        try {
            this.back.accept(server.accept());
        } catch (final SocketTimeoutException ignored) {
        }
    }
582751
def socket_monitor_loop(self):
        '''  '''
        try:
            while True:
                gevent.socket.wait_read(self.socket.fileno())

                self._handle_log_rotations()
                self.capture_packet()
        finally:
            self.clean_up()
715544
def run(self):
        '''
        
        '''
        self.thread = Thread(target=self.__processQueue)
        self.thread.start()
1232847
def mainloop(self):
        
        while self.keep_going:
            with self.lock:
                if self.on_connect and not self.readable(2):
                    self.on_connect()
                    self.on_connect = None
                if not self.keep_going:
                    break
                self.process_once()
1195778
def run(self):
        
        while True:
            try:
                data = None
                # Wait for a connection
                if self.debug:
                    self.py3_wrapper.log("waiting for a connection")

                connection, client_address = self.sock.accept()
                try:
                    if self.debug:
                        self.py3_wrapper.log("connection from")

                    data = connection.recv(MAX_SIZE)
                    if data:
                        data = json.loads(data.decode("utf-8"))
                        if self.debug:
                            self.py3_wrapper.log(u"received %s" % data)
                        self.command_runner.run_command(data)
                finally:
                    # Clean up the connection
                    connection.close()
            except Exception:
                if data:
                    self.py3_wrapper.log("Command error")
                    self.py3_wrapper.log(data)
                self.py3_wrapper.report_exception("command failed")
920064
def Run(self):
    """"""
    count = 0
    for count, input_data in enumerate(self.GetInput()):
      if count % 2000 == 0:
        logging.debug("%d processed.", count)
      args = (input_data, self.out_queue, self.token)
      self.thread_pool.AddTask(
          target=self.IterFunction, args=args, name=self.THREAD_POOL_NAME)

    while count >= 0:
      try:
        # We only use the timeout to wait if we got to the end of the Queue but
        # didn't process everything yet.
        out = self.out_queue.get(timeout=self.QUEUE_TIMEOUT, block=True)
        if out:
          yield out
          count -= 1
      except queue.Empty:
        break

    # Join and stop to clean up the threadpool.
    self.thread_pool.Stop(join_timeout=THREADPOOL_JOIN_TIMEOUT)
154313
def run(self):
        
        # Bind the socket to the port
        logging.info("Server starts socket on {addr}".format(addr=self.server_address))

        # Create a UDS socket
        if six.PY2:
            sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
            self.listen(sock)
            sock.close()
        else:
            with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
                self.listen(sock)
        try:
            os.unlink(self.server_address)
        except OSError:
            if os.path.exists(self.server_address):
                raise
        return
715936
def run(self, **kwargs):
        

        try:
            loop = IOLoop()
            app = self.make_app()
            app.listen(self.port)
            loop.start()

        except socket.error as serr:
            # Re raise the socket error if not "[Errno 98] Address already in use"
            if serr.errno != errno.EADDRINUSE:
                raise serr
            else:
                logger.warning('The webserver port {} is already used. May be the HttpRobotServer is already running or another software is using this port.'.format(self.port))
1053820
def main_loop():
    ''''''
    while True:
        if mestate is None or mestate.exit:
            return
        while not mestate.input_queue.empty():
            line = mestate.input_queue.get()
            cmds = line.split(';')
            for c in cmds:
                process_stdin(c)
        time.sleep(0.1)
1239659
def run(self, loop=None):
        
        if loop is None:
            loop = asyncio.get_event_loop()

        self.loop = loop

        loop.run_until_complete(self.startup())

        for func in self.tasks:
            self.start_task(func)

        try:
            task = self.start_task(self.main_task)
            loop.run_until_complete(task)
        except (KeyboardInterrupt, SystemError):
            print("Attempting graceful shutdown, press Ctrl-C again to exit", flush=True)

            def shutdown_exception_handler(_loop, context):
                if "exception" not in context or not isinstance(context["exception"], asyncio.CancelledError):
                    _loop.default_exception_handler(context)
            loop.set_exception_handler(shutdown_exception_handler)

            tasks = asyncio.gather(*self._started_tasks, loop=loop, return_exceptions=True)
            tasks.add_done_callback(lambda _: loop.stop())
            tasks.cancel()

            while not tasks.done() and not loop.is_closed():
                loop.run_forever()
        finally:
            loop.run_until_complete(self.shutdown())
            loop.run_until_complete(self.cleanup())
            loop.close()
1334190
public function run(): void
    {
        $this->connectionManager->listen();

        while ($this->loop->shouldContinue()) {
            /*
             * If there's nothing changed on any of the sockets, the server
             * will sleep and other processes will have a change to run. Control
             * this behaviour with the timeout options.
             */
            $this->connectionManager->selectAndProcess();

            /*
             * If the application wants to perform periodic operations or queries
             * and push updates to clients based on the result then that logic can
             * be implemented in the 'onUpdate' method.
             */
            foreach ($this->applications as $application) {
                if (method_exists($application, 'onUpdate')) {
                    $application->onUpdate();
                }
            }
        }
    }
190429
public function run()
    {
        $this->log("Server listening on {$this->host}:{$this->port}");
        $this->socket->listen($this->port, $this->host);
        $this->loop->run();
    }