Beispiel #1
0
    def startTest(self, callback, min_timeout=5):
        from Tribler.Main.vwxGUI.GuiUtility import GUIUtility
        from Tribler.Main.tribler import run

        self.hadSession = False
        starttime = time.time()

        def call_callback():
            took = time.time() - starttime
            if took > min_timeout:
                callback()
            else:
                self.Call(min_timeout - took, callback)

        def wait_for_frame():
            print >> sys.stderr, "tgs: GUIUtility ready, staring to wait for frame to be ready"
            self.frame = self.guiUtility.frame
            self.frame.Maximize()
            self.CallConditional(30, lambda: self.frame.ready, call_callback)

        def wait_for_init():
            print >> sys.stderr, "tgs: lm initcomplete, staring to wait for GUIUtility to be ready"
            self.guiUtility = GUIUtility.getInstance()
            self.CallConditional(30, lambda: self.guiUtility.registered, wait_for_frame)

        def wait_for_guiutility():
            print >> sys.stderr, "tgs: waiting for guiutility instance"
            self.CallConditional(30, lambda: GUIUtility.hasInstance(), wait_for_init)

        def wait_for_instance():
            print >> sys.stderr, "tgs: found instance, staring to wait for lm to be initcomplete"
            self.session = Session.get_instance()
            self.lm = self.session.lm

            self.CallConditional(30, lambda: self.lm.initComplete, wait_for_guiutility)

        def wait_for_session():
            self.hadSession = True
            print >> sys.stderr, "tgs: waiting for session instance"
            self.CallConditional(30, lambda: Session.has_instance(), wait_for_instance)

        self.CallConditional(30, lambda: Session.has_instance, lambda: TestAsServer.startTest(self, wait_for_session))

        # modify argv to let tribler think its running from a different directory
        sys.argv = [os.path.abspath('./.exe')]
        run()

        assert self.hadSession, 'Did not even create a session'
    def startTest(self, callback):
        self.quitting = False

        def wait_for_init():
            print >>sys.stderr, "tgs: lm initcomplete, staring to wait for frame to be ready"

            self.guiUtility = GUIUtility.getInstance()
            self.frame = self.guiUtility.frame

            self.CallConditional(30, lambda: self.frame.ready, callback)

        def wait_for_instance():
            print >>sys.stderr, "tgs: found instance, staring to wait for lm to be initcomplete"
            self.session = Session.get_instance()
            self.lm = self.session.lm

            self.CallConditional(30, lambda: self.lm.initComplete, wait_for_init)

        self.CallConditional(30, Session.has_instance, wait_for_instance)

        # modify argv to let tribler think its running from a different directory
        sys.argv = [os.path.abspath("./.exe")]
        run()
Beispiel #3
0
    def startTest(self, callback):
        self.quitting = False

        def wait_for_init():
            print >> sys.stderr, "tgs: lm initcomplete, staring to wait for frame to be ready"

            self.guiUtility = GUIUtility.getInstance()
            self.frame = self.guiUtility.frame

            self.CallConditional(30, lambda: self.frame.ready, callback)

        def wait_for_instance():
            print >> sys.stderr, "tgs: found instance, staring to wait for lm to be initcomplete"
            self.session = Session.get_instance()
            self.lm = self.session.lm

            self.CallConditional(30, lambda: self.lm.initComplete,
                                 wait_for_init)

        self.CallConditional(30, Session.has_instance, wait_for_instance)

        #modify argv to let tribler think its running from a different directory
        sys.argv = [os.path.abspath('./.exe')]
        run()
Beispiel #4
0
            
            if event == 'c_return':
                index += 1
            
            stats[lockobj][name][index] = time()
            stats[lockobj][name][6] = index == 1
            
            doCheck = event == 'c_return' or (event == 'c_call' and callname == 'release')
            if doCheck:
                took = stats[lockobj][name][index] - stats[lockobj][name][index-1]
                if took > 2:
                    print >> sys.stderr, "%s waited more than %.2f to %s lock %s:%d"%(name, took, callname, filename, lineno)
                    if hasattr(threadlocal, "lines"):
                        for line in threadlocal.lines:
                            print >> sys.stderr, "\t", line
            
            if index == 0:
                for otherthread in stats[lockobj]:
                    if otherthread != name:
                        if stats[lockobj][otherthread][6]:
                            print >> sys.stderr, "%s waiting for lock acquired by %s"%(name, otherthread)
                            if False and hasattr(threadlocal, "lines"):
                                for line in threadlocal.lines:
                                    print >> sys.stderr, "\t", line
                                   
if __name__ == '__main__':
    sys.setprofile(lock_profile)
    setprofile(lock_profile)
    
    run()
Beispiel #5
0
            stats[lockobj][name][6] = index == 1

            doCheck = event == 'c_return' or (event == 'c_call'
                                              and callname == 'release')
            if doCheck:
                took = stats[lockobj][name][index] - stats[lockobj][name][index
                                                                          - 1]
                if took > 2:
                    logger.info("%s waited more than %.2f to %s lock %s:%d",
                                name, took, callname, filename, lineno)
                    if hasattr(threadlocal, "lines"):
                        for line in threadlocal.lines:
                            logger.info("\t%s", line)

            if index == 0:
                for otherthread in stats[lockobj]:
                    if otherthread != name:
                        if stats[lockobj][otherthread][6]:
                            logger.info("%s waiting for lock acquired by %s",
                                        name, otherthread)
                            if False and hasattr(threadlocal, "lines"):
                                for line in threadlocal.lines:
                                    logger.info("\t%s", line)


if __name__ == '__main__':
    sys.setprofile(lock_profile)
    setprofile(lock_profile)

    run()