def run(self, data_cb):
        """Run the event loop."""
        if self._error:
            err = self._error
            if isinstance(self._error, KeyboardInterrupt):
                # KeyboardInterrupt is not destructive(it may be used in
                # the REPL).
                # After throwing KeyboardInterrupt, cleanup the _error field
                # so the loop may be started again
                self._error = None
            raise err
        self._on_data = data_cb
        if threading.current_thread() == main_thread:
            self._setup_signals([signal.SIGINT, signal.SIGTERM])
        debug('Entering event loop')
        self._run()
        debug('Exited event loop')
        if threading.current_thread() == main_thread:
            self._teardown_signals()
            signal.signal(signal.SIGINT, default_int_handler)
        self._on_data = None
def run ( self , data_cb ) : if self . _error : err = self . _error if isinstance ( self . _error , KeyboardInterrupt ) : self . _error = None raise err self . _on_data = data_cb if threading . current_thread ( ) == main_thread : self . _setup_signals ( [ signal . SIGINT , signal . SIGTERM ] ) debug ( 'Entering event loop' ) self . _run ( ) debug ( 'Exited event loop' ) if threading . current_thread ( ) == main_thread : self . _teardown_signals ( ) signal . signal ( signal . SIGINT , default_int_handler ) self . _on_data = None
Run the event loop.