Ejemplo n.º 1
0
    def test_myself_may_not_be_me_any_more(self):
        import gc
        from _stackless import clonable

        counter = [0]

        def runner():
            while 1:
                assert clonable.getcurrent() is coro
                counter[0] += 1
                main.switch()

        main = clonable.getcurrent()
        coro = clonable()
        coro.bind(runner)

        coro.switch()
        assert counter == [1]

        assert clonable.getcurrent() is main
        coro1 = coro.clone()
        assert counter == [1]
        assert clonable.getcurrent() is main
        coro.switch()
        assert counter == [2]
        coro.switch()
        assert counter == [3]
        assert clonable.getcurrent() is main
        del coro1
        gc.collect()
        #print "collected!"
        assert clonable.getcurrent() is main
        assert counter == [3]
        coro.switch()
        assert clonable.getcurrent() is main
        assert counter == [4]
Ejemplo n.º 2
0
    def test_myself_may_not_be_me_any_more(self):
        import gc
        from _stackless import clonable

        counter = [0]

        def runner():
            while 1:
                assert clonable.getcurrent() is coro
                counter[0] += 1
                main.switch()

        main = clonable.getcurrent()
        coro = clonable()
        coro.bind(runner)

        coro.switch()
        assert counter == [1]

        assert clonable.getcurrent() is main
        coro1 = coro.clone()
        assert counter == [1]
        assert clonable.getcurrent() is main
        coro.switch()
        assert counter == [2]
        coro.switch()
        assert counter == [3]
        assert clonable.getcurrent() is main
        del coro1
        gc.collect()
        #print "collected!"
        assert clonable.getcurrent() is main
        assert counter == [3]
        coro.switch()
        assert clonable.getcurrent() is main
        assert counter == [4]
Ejemplo n.º 3
0
 def runner():
     while 1:
         assert clonable.getcurrent() is coro
         counter[0] += 1
         main.switch()
Ejemplo n.º 4
0
 def runner():
     while 1:
         assert clonable.getcurrent() is coro
         counter[0] += 1
         main.switch()