Пример #1
0
    def main_loop(self):
        """Run main loop to execute tests"""

        try:
            monitor = stream_monitor.StreamMonitor(
                idle_handler=self._handle_system_idle,
                loop_hook=self._loop_hook)
            self.stream_monitor = monitor
            self.monitor_stream('faucet', self.faucet_events.sock,
                                self._handle_faucet_events)
            if self.event_trigger:
                self._flush_faucet_events()
            LOGGER.info('Entering main event loop.')
            LOGGER.info(
                'See docs/troubleshooting.md if this blocks for more than a few minutes.'
            )
            self.stream_monitor.event_loop()
        except Exception as e:
            LOGGER.error('Event loop exception: %s', e)
            LOGGER.exception(e)
            self.exception = e
        except KeyboardInterrupt as e:
            LOGGER.error('Keyboard Interrupt')
            LOGGER.exception(e)
            self.exception = e

        if self.config.get('use_console'):
            LOGGER.info('Dropping into interactive command line')
            self.network.cli()

        self._terminate()
Пример #2
0
    def main_loop(self):
        """Run main loop to execute tests"""
        use_console = self.config.get('use_console')

        if self.flap_ports:
            self.network.flap_interface_ports()

        try:
            monitor = stream_monitor.StreamMonitor(
                idle_handler=self._handle_system_idle,
                loop_hook=self._loop_hook)
            self.stream_monitor = monitor
            self.monitor_stream('faucet', self.faucet_events.sock,
                                self._handle_faucet_event)
            if self.event_trigger:
                self._flush_faucet_events()
            LOGGER.info('Entering main event loop.')
            self.stream_monitor.event_loop()
        except Exception as e:
            LOGGER.error('Event loop exception: %s', e)
            LOGGER.exception(e)
            self.exception = e
        except KeyboardInterrupt as e:
            LOGGER.error('Keyboard Interrupt')
            LOGGER.exception(e)

        keyboard_console = not self.single_shot and not self.exception
        if use_console or keyboard_console:
            LOGGER.info('Dropping into interactive command line')
            self.network.cli()

        self._terminate()
Пример #3
0
    def main_loop(self):
        """Run main loop to execute tests"""

        try:
            monitor = stream_monitor.StreamMonitor(
                idle_handler=self._handle_system_idle,
                loop_hook=self._loop_hook,
                timeout_sec=20)  # Polling rate
            self.stream_monitor = monitor
            self.monitor_stream('faucet',
                                self.faucet_events.sock,
                                self._handle_faucet_events_locked,
                                priority=10)
            LOGGER.info('Entering main event loop.')
            LOGGER.info(
                'See docs/troubleshooting.md if this blocks for more than a few minutes.'
            )
            while self.stream_monitor.event_loop():
                self._reap_stale_ports()
                self._module_heartbeat()
        except Exception as e:
            LOGGER.error('Event loop exception: %s', e)
            LOGGER.exception(e)
            self.exception = e
        except KeyboardInterrupt as e:
            LOGGER.error('Keyboard Interrupt')
            LOGGER.exception(e)
            self.exception = e

        if self.config.get('use_console'):
            LOGGER.info('Dropping into interactive command line')
            self.network.cli()

        self._terminate()
Пример #4
0
 def _create_stream_monitor(self):
     return stream_monitor.StreamMonitor(
         idle_handler=self._handle_system_idle,
         loop_hook=self._loop_hook,
         timeout_sec=20)  # Polling rate