Exemple #1
0
def _bootstrap_inner(self):
    try:
        self._set_ident()
        self._Thread__started.set()
        with _active_limbo_lock:
            _active[self._Thread__ident] = self
            del _limbo[self]

        if _trace_hook:
            _sys.settrace(_trace_hook)
        if _profile_hook:
            _sys.setprofile(_profile_hook)

        try:
            self.run()
        except SystemExit:
            pass
        except:
            if _sys:
                _sys.stderr.write("Exception in thread %s:\n%s\n" %
                                    (self.name, _format_exc()))
            else:
                exc_type, exc_value, exc_tb = self._exc_info()
                try:
                    self._stderr.write(
                        (
                        "Exception in thread " + self.name +
                        " (most likely raised during interpreter shutdown):")
                        )

                    self._stderr.write("Traceback (most recent call last):")
                    while exc_tb:
                        self._stderr.write(
                            '  File "%s", line %s, in %s' %
                            (exc_tb.tb_frame.f_code.co_filename,
                                exc_tb.tb_lineno,
                                exc_tb.tb_frame.f_code.co_name))

                        exc_tb = exc_tb.tb_next
                    self._stderr.write("%s: %s" % (exc_type, exc_value))
                finally:
                    del exc_type, exc_value, exc_tb
        finally:
            pass
    finally:
        with _active_limbo_lock:
            self._Thread__stop()
            try:
                del _active[self._Thread__ident]
            except:
                pass
Exemple #2
0
        def _bootstrap_inner(self):  # NOQA
            try:
                self._set_ident()
                self._started.set()
                with _active_limbo_lock:
                    _active[self._ident] = self
                    del _limbo[self]

                if _trace_hook:
                    _sys.settrace(_trace_hook)
                if _profile_hook:
                    _sys.setprofile(_profile_hook)

                try:
                    self.run()
                except SystemExit:
                    pass
                except:
                    if _sys:
                        _sys.stderr.write("Exception in thread %s:\n%s\n" %
                                          (self.name, _format_exc()))
                    else:
                        exc_type, exc_value, exc_tb = self._exc_info()
                        try:
                            self._stderr.write(
                                "Exception in thread " + self.name + " (most "
                                "likely raised during interpreter shutdown):")

                            self._stderr.write("Traceback (most recent call "
                                               "last):")
                            while exc_tb:
                                self._stderr.write(
                                    '  File "%s", line %s, in %s' %
                                    (exc_tb.tb_frame.f_code.co_filename,
                                     exc_tb.tb_lineno,
                                     exc_tb.tb_frame.f_code.co_name))

                                exc_tb = exc_tb.tb_next
                            self._stderr.write("%s: %s" %
                                               (exc_type, exc_value))
                        finally:
                            del exc_type, exc_value, exc_tb
                finally:
                    pass
            finally:
                with _active_limbo_lock:
                    self._stop()
                    try:
                        del _active[self._ident]
                    except:
                        pass