(self, socket=None)
Run this manager. The method fires the
        :class:`~.events.Started` event and then continuously
        calls :meth:`~.tick`.

        The method returns when the manager's
        :meth:`~.stop` method is invoked.

        If invoked by a programs main thread, a signal handler for
        the ``INT`` and ``TERM`` signals is installed. This handler
        fires the corresponding :class:`~.events.Signal`
        events and then calls :meth:`~.stop` for the manager.
Run this manager. The method fires the
        :class:`~.events.Started` event and then continuously
        calls :meth:`~.tick`.
Run this manager . The method fires the : class : ~ . events . Started event and then continuously calls : meth : ~ . tick .
def run(self, socket=None):
        """
        Run this manager. The method fires the
        :class:`~.events.Started` event and then continuously
        calls :meth:`~.tick`.

        The method returns when the manager's
        :meth:`~.stop` method is invoked.

        If invoked by a programs main thread, a signal handler for
        the ``INT`` and ``TERM`` signals is installed. This handler
        fires the corresponding :class:`~.events.Signal`
        events and then calls :meth:`~.stop` for the manager.
        """

        atexit.register(self.stop)

        if current_thread().getName() == "MainThread":
            try:
                set_signal_handler(SIGINT, self._signal_handler)
                set_signal_handler(SIGTERM, self._signal_handler)
            except ValueError:
                # Ignore if we can't install signal handlers
                pass

        self._running = True
        self.root._executing_thread = current_thread()

        # Setup Communications Bridge

        if socket is not None:
            from circuits.core.bridge import Bridge
            Bridge(socket, channel=socket.channel).register(self)

        self.fire(started(self))

        try:
            while self.running or self._queue:
                self.tick()
            # Fading out, handle remaining work from stop event
            for _ in range(3):
                self.tick()
        except Exception as exc:
            stderr.write("Unhandled ERROR: {0:s}\n".format(exc))
            stderr.write(format_exc())
        finally:
            try:
                self.tick()
            except:
                pass

        self.root._executing_thread = None
        self.__thread = None
        self.__process = None
def run ( self , socket = None ) : atexit . register ( self . stop ) if current_thread ( ) . getName ( ) == "MainThread" : try : set_signal_handler ( SIGINT , self . _signal_handler ) set_signal_handler ( SIGTERM , self . _signal_handler ) except ValueError : # Ignore if we can't install signal handlers pass self . _running = True self . root . _executing_thread = current_thread ( ) # Setup Communications Bridge if socket is not None : from circuits . core . bridge import Bridge Bridge ( socket , channel = socket . channel ) . register ( self ) self . fire ( started ( self ) ) try : while self . running or self . _queue : self . tick ( ) # Fading out, handle remaining work from stop event for _ in range ( 3 ) : self . tick ( ) except Exception as exc : stderr . write ( "Unhandled ERROR: {0:s}\n" . format ( exc ) ) stderr . write ( format_exc ( ) ) finally : try : self . tick ( ) except : pass self . root . _executing_thread = None self . __thread = None self . __process = None