Beispiel #1
0
    def early_shutdown(self):
        """ Called as soon as Session shutdown is initiated. Used to start
        shutdown tasks that takes some time and that can run in parallel
        to checkpointing, etc.
        """
        print >> sys.stderr, "tlm: early_shutdown"

        # Note: sesslock not held
        self.shutdownstarttime = timemod.time()
        if self.rtorrent_handler:
            self.rtorrent_handler.shutdown()
            self.rtorrent_handler.delInstance()
        if self.torrent_checking:
            self.torrent_checking.shutdown()
            self.torrent_checking.delInstance()

        if self.dispersy:
            print >> sys.stderr, "lmc: Dispersy shutdown", "[%d]" % id(
                self.dispersy)
            self.dispersy.stop(666.666)
        else:
            self.database_thread.shutdown(True)

        if self.session.get_megacache():
            self.peer_db.delInstance()
            self.torrent_db.delInstance()
            self.mypref_db.delInstance()
            self.votecast_db.delInstance()
            self.channelcast_db.delInstance()
            self.nb_db.delInstance()
            self.ue_db.delInstance()
            self.cat.delInstance()
            self.term.delInstance()

            from Tribler.Core.CacheDB.sqlitecachedb import unregister
            unregister()

        # SWIFTPROC
        if self.spm is not None:
            self.spm.early_shutdown()

        if self.mainline_dht:
            from Tribler.Core.DecentralizedTracking import mainlineDHT
            mainlineDHT.deinit(self.mainline_dht)
Beispiel #2
0
    def early_shutdown(self):
        """ Called as soon as Session shutdown is initiated. Used to start
        shutdown tasks that takes some time and that can run in parallel
        to checkpointing, etc.
        """
        print >> sys.stderr, "tlm: early_shutdown"

        # Note: sesslock not held
        self.shutdownstarttime = timemod.time()
        if self.rtorrent_handler:
            self.rtorrent_handler.shutdown()
            self.rtorrent_handler.delInstance()
        if self.torrent_checking:
            self.torrent_checking.shutdown()
            self.torrent_checking.delInstance()

        if self.dispersy:
            print >> sys.stderr, "lmc: Dispersy shutdown", "[%d]" % id(self.dispersy)
            self.dispersy.stop(666.666)
        else:
            self.database_thread.shutdown(True)

        if self.session.get_megacache():
            self.peer_db.delInstance()
            self.torrent_db.delInstance()
            self.mypref_db.delInstance()
            self.votecast_db.delInstance()
            self.channelcast_db.delInstance()
            self.nb_db.delInstance()
            self.ue_db.delInstance()
            self.cat.delInstance()
            self.term.delInstance()

            from Tribler.Core.CacheDB.sqlitecachedb import unregister
            unregister()

        # SWIFTPROC
        if self.spm is not None:
            self.spm.early_shutdown()

        if self.mainline_dht:
            from Tribler.Core.DecentralizedTracking import mainlineDHT
            mainlineDHT.deinit(self.mainline_dht)
Beispiel #3
0
    def tearDown(self):
        self.annotate(self._testMethodName, start=False)
        """ unittest test tear down code """
        del self.guiUtility
        del self.frame
        del self.lm
        del self.session

        from Tribler.Core.CacheDB.sqlitecachedb import unregister
        unregister()

        sleep(10)
        gc.collect()

        ts = enumerate_threads()
        print >> sys.stderr, "teardown: Number of threads still running", len(
            ts)
        for t in ts:
            print >> sys.stderr, "teardown: Thread still running", t.getName(
            ), "daemon", t.isDaemon(), "instance:", t

        dhtlog = os.path.join('.Tribler', 'pymdht.log')
        if os.path.exists(dhtlog):
            print >> sys.stderr, "teardown: content of pymdht.log"
            f = open(dhtlog, 'r')
            for line in f:
                line = line.strip()
                if line:
                    print >> sys.stderr, line
            f.close()
            print >> sys.stderr, "teardown: finished printing content of pymdht.log"

        shutil.rmtree(".Tribler")
        shutil.rmtree("TriblerDownloads")

        for boolean, reason in self.asserts:
            assert boolean, reason

        assert not os.path.exists(".Tribler"), ".Tribler should not exist"
        assert not os.path.exists(
            "TriblerDownloads"), "TriblerDownloads should not exist"
    def tearDown(self):
        self.annotate(self._testMethodName, start=False)

        """ unittest test tear down code """
        del self.guiUtility
        del self.frame
        del self.lm
        del self.session

        from Tribler.Core.CacheDB.sqlitecachedb import unregister

        unregister()

        sleep(10)
        gc.collect()

        ts = enumerate_threads()
        print >>sys.stderr, "teardown: Number of threads still running", len(ts)
        for t in ts:
            print >>sys.stderr, "teardown: Thread still running", t.getName(), "daemon", t.isDaemon(), "instance:", t

        dhtlog = os.path.join(".Tribler", "pymdht.log")
        if os.path.exists(dhtlog):
            print >>sys.stderr, "teardown: content of pymdht.log"
            f = open(dhtlog, "r")
            for line in f:
                line = line.strip()
                if line:
                    print >>sys.stderr, line
            f.close()
            print >>sys.stderr, "teardown: finished printing content of pymdht.log"

        shutil.rmtree(".Tribler")
        shutil.rmtree("TriblerDownloads")

        for boolean, reason in self.asserts:
            assert boolean, reason

        assert not os.path.exists(".Tribler"), ".Tribler should not exist"
        assert not os.path.exists("TriblerDownloads"), "TriblerDownloads should not exist"