def run(self, reactor):
        """
        Run reactor under the hotshot profiler.
        """
        try:
            import hotshot.stats
        except (ImportError, __HOLE__), e:
            # Certain versions of Debian (and Debian derivatives) raise
            # SystemExit when importing hotshot if the "non-free" profiler
            # module is not installed.  Someone eventually recognized this
            # as a bug and changed the Debian packaged Python to raise
            # ImportError instead.  Handle both exception types here in
            # order to support the versions of Debian which have this
            # behavior.  The bug report which prompted the introduction of
            # this highly undesirable behavior should be available online at
            # <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=334067>.
            # There seems to be no corresponding bug report which resulted
            # in the behavior being removed. -exarkun
            self._reportImportError("hotshot", e)

        # this writes stats straight out
        p = hotshot.Profile(self.profileOutput)
        p.runcall(reactor.run)
        if self.saveStats:
            # stats are automatically written to file, nothing to do
            return
        else:
            s = hotshot.stats.load(self.profileOutput)
            s.strip_dirs()
            s.sort_stats(-1)
            if getattr(s, 'stream', None) is not None:
                # Python 2.5 and above supports a stream attribute
                s.stream = open(self.profileOutput, 'w')
                s.print_stats()
                s.stream.close()
            else:
                # But we have to use a trick for Python < 2.5
                tmp, sys.stdout = sys.stdout, open(self.profileOutput, 'w')
                try:
                    s.print_stats()
                finally:
                    sys.stdout, tmp = tmp, sys.stdout
                    tmp.close()
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/application/app.py/HotshotRunner.run