Initializes and runs the listening loop continually

        :param markAlive: Whether this should ping the Facebook server each time the loop runs
        :type markAlive: bool
506801
def listen(self, markAlive=None):
        
        if markAlive is not None:
            self.setActiveStatus(markAlive)

        self.startListening()
        self.onListening()

        while self.listening and self.doOneListen():
            pass

        self.stopListening()
887918
async def _deferred_init(self):
        

        hook_path = self.make_hook_path()
        url = urljoin(settings.BERNARD_BASE_URL, hook_path)
        await self.call('setWebhook', url=url)
        logger.info('Setting Telegram webhook to "%s"', url)
1057530
def start(self, initial_delay=0):
        
        if self.listener is None:
            raise exceptions.NoAsyncListenerError
        elif self._enabled:
            return

        self._enabled = True
1100578
def start(self, start_loop=True):
        
        txaio.start_logging()
        runner = self.setup_runner()
        if start_loop:
            try:
                runner.run(Component)
            except EventifyHandlerInitializationFailed as initError:
                logging.error('Unable to initialize handler: %s.' % initError.message)
                sys.exit(1)
            except ConnectionRefusedError:
                logging.error('Unable to connect to crossbar instance. Is it running?')
                sys.exit(1)
            except KeyboardInterrupt:
                logging.info('User initiated shutdown')
                loop = asyncio.get_event_loop()
                loop.stop()
                sys.exit(1)
            self.check_event_loop()
            self.reconnect()
        else:
            return runner.run(
                Component,
                start_loop=start_loop
            )
1166525
def run(self, host="localhost", port=8000, shutdown_timeout=60.0, **kwargs):
        
        print("Running service on http://localhost:%i. " % port + \
                                            "Press Ctrl+C to terminate.")

        # apply the configuration to the service config
        self.config.port = port
        self.config.host = host

        # start the loop
        try:
            # if an event broker has been created for this service
            if self.event_broker:
                # start the broker
                self.event_broker.start()
                # announce the service
                self.loop.run_until_complete(self.announce())

            # the handler for the http server
            http_handler = self.app.make_handler()
            # create an asyncio server
            self._http_server = self.loop.create_server(http_handler, host, port)

            # grab the handler for the server callback
            self._server_handler = self.loop.run_until_complete(self._http_server)
            # start the event loop
            self.loop.run_forever()

        # if the user interrupted the server
        except KeyboardInterrupt:
            # keep going
            pass

        # when we're done
        finally:
            try:
                # clean up the service
                self.cleanup()
            # if we end up closing before any variables get assigned
            except UnboundLocalError:
                # just ignore it (there was nothing to close)
                pass

            # close the event loop
            self.loop.close()
441630
private void run(PortFile portFile, PrintStream err, int keepalive) {
        boolean fileDeleted = false;
        long timeSinceLastCompile;
        try {
            // Every 5 second (check_portfile_interval) we test if the portfile has disappeared => quit
            // Or if the last request was finished more than 125 seconds ago => quit
            // 125 = seconds_of_inactivity_before_shutdown+check_portfile_interval
            serverSocket.setSoTimeout(CHECK_PORTFILE_INTERVAL*1000);
            for (;;) {
                try {
                    Socket s = serverSocket.accept();
                    CompilerThread ct = compilerPool.grabCompilerThread();
                    ct.setSocket(s);
                    compilerPool.execute(ct);
                    flushLog();
                } catch (java.net.SocketTimeoutException e) {
                    if (compilerPool.numActiveRequests() > 0) {
                        // Never quit while there are active requests!
                        continue;
                    }
                    // If this is the timeout after the portfile
                    // has been deleted by us. Then we truly stop.
                    if (fileDeleted) {
                        log("Quitting because of "+(keepalive+CHECK_PORTFILE_INTERVAL)+" seconds of inactivity!");
                        break;
                    }
                    // Check if the portfile is still there.
                    if (!portFile.exists()) {
                        // Time to quit because the portfile was deleted by another
                        // process, probably by the makefile that is done building.
                        log("Quitting because portfile was deleted!");
                        flushLog();
                        break;
                    }
                    // Check if portfile.stop is still there.
                    if (portFile.markedForStop()) {
                        // Time to quit because another process touched the file
                        // server.port.stop to signal that the server should stop.
                        // This is necessary on some operating systems that lock
                        // the port file hard!
                        log("Quitting because a portfile.stop file was found!");
                        portFile.delete();
                        flushLog();
                        break;
                    }
                    // Does the portfile still point to me?
                    if (!portFile.stillMyValues()) {
                        // Time to quit because another build has started.
                        log("Quitting because portfile is now owned by another javac server!");
                        flushLog();
                        break;
                    }

                    // Check how long since the last request finished.
                    long diff = System.currentTimeMillis() - compilerPool.lastRequestFinished();
                    if (diff < keepalive * 1000) {
                        // Do not quit if we have waited less than 120 seconds.
                        continue;
                    }
                    // Ok, time to quit because of inactivity. Perhaps the build
                    // was killed and the portfile not cleaned up properly.
                    portFile.delete();
                    fileDeleted = true;
                    log("" + keepalive + " seconds of inactivity quitting in "
                        + CHECK_PORTFILE_INTERVAL + " seconds!");
                    flushLog();
                    // Now we have a second 5 second grace
                    // period where javac remote requests
                    // that have loaded the data from the
                    // recently deleted portfile can connect
                    // and complete their requests.
                }
            }
        } catch (Exception e) {
            e.printStackTrace(err);
            e.printStackTrace(theLog);
            flushLog();
        } finally {
            compilerPool.shutdown();
        }
        long realTime = System.currentTimeMillis() - serverStart;
        log("Shutting down.");
        log("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms");
        flushLog();
    }
522670
def run(self):
        
        try:
            self.initialize_connection()
        except ChromecastConnectionError:
            self._report_connection_status(
                ConnectionStatus(CONNECTION_STATUS_DISCONNECTED,
                                 NetworkAddress(self.host, self.port)))
            return

        self.heartbeat_controller.reset()
        self._force_recon = False
        logging.debug("Thread started...")
        while not self.stop.is_set():

            if self.run_once() == 1:
                break

        # Clean up
        self._cleanup()
651218
public void initSynchronous(Path monitoredFile) throws IOException {
        final Runnable watcher = initializeWatcherWithDirectory(monitoredFile, new CountDownLatch(1), new CountDownLatch(1));
        watcher.run();
    }
1111448
def _run_listeners(self, line):
        
        for regex, callbacks in self.listeners.iteritems():
            match = regex.match(line)

            if not match:
                continue

            for callback in callbacks:
                callback(*match.groups())
308305
def listen(self, once=False):
        

        if once:
            # we listen for time event and return false so our
            # run_queues function will be also falsy and break the loop
            self.add_listener("time", lambda _: False)
        return self.conn.listen()
310820
@Override
    public void doSessionCreatedListeners() {
        runManagementTask(new Runnable() {
            @Override
            public void run() {
                try {
                    // The particular management listeners change on strategy, so get them here.
                    for (final SessionManagementListener listener : getManagementListeners()) {
                        listener.doSessionCreated(SessionManagementBeanImpl.this);
                    }

                    // XXX Should we include a 'markChanged()' here?
                } catch (Exception ex) {
                    logger.warn("Error during doSessionCreated session listener notifications:", ex);
                }
            }
        });
    }
996094
async def _pinger(self):
        '''
        

        '''
        async def _do_ping():
            try:
                await pinger_facade.Ping()
                await asyncio.sleep(10, loop=self.loop)
            except CancelledError:
                pass

        pinger_facade = client.PingerFacade.from_connection(self)
        try:
            while True:
                await utils.run_with_interrupt(
                    _do_ping(),
                    self.monitor.close_called,
                    loop=self.loop)
                if self.monitor.close_called.is_set():
                    break
        except websockets.exceptions.ConnectionClosed:
            # The connection has closed - we can't do anything
            # more until the connection is restarted.
            log.debug('ping failed because of closed connection')
            pass
426238
public function onReady()
    {
        $this->createXMLStream();
        $this->startXMLStream();
        $this->keepaliveTimer = setTimeout(function ($timer) {
            $this->ping();
        }, 1e6 * 30);
    }
1218844
def listen(self):
        

        self.listening = True
        if self.threading:
            from threading import Thread
            self.listen_thread = Thread(target=self.listen_loop)
            self.listen_thread.daemon = True
            self.listen_thread.start()

            self.scheduler_thread = Thread(target=self.scheduler)
            self.scheduler_thread.daemon = True
            self.scheduler_thread.start()

        else:
            self.listen_loop()
376119
def listen(&block)
      return if @listeners.any?
      @listeners = @queues.map do |queue|
        QueueListener.new(queue)
      end

      @listeners.each do |listener|
        listener.listen(&block)
      end
    end
829652
async def _keepalive(self):
        '''
            
        '''
        while self.protocol:
            vers = await self.RPC('server.version')
            logger.debug("Server version: " + repr(vers))

            # Five minutes isn't really enough anymore; looks like
            # servers are killing 2-minute old idle connections now.
            # But decreasing interval this seems rude.
            await asyncio.sleep(600)
1111451
def start(self, blocking=False):
        
        try:
            self._init_listen_socket()
        except:
            self.exception(u"Failed to init listen socket ({}:{})".format(
                self._listen_ip, self._listen_port
            ))
            self._shutdown_listen_socket()
            raise SensorStartException("Listen socket init failed")
        self.info(u"Listening on {}:{}".format(
            self._listen_ip, self._listen_port
        ))

        super(Sensor, self).start(False)
        try:
            a_thread = threading.Thread(
                target=self._thread_wrapper,
                args=(self._receiving,)
            )
            a_thread.daemon = True
            a_thread.start()
        except:
            self.exception("Failed to run receive loop")
            raise SensorStartException("Packet loop failed")
        super(Sensor, self).start(blocking)