Exemple #1
0
        def inner():
            nonlocal loop_count
            i = loop_count
            print('starting loop', loop_count)
            loop_count += 1

            if loop_count == 10:
                print('loop {} stopped'.format(i))
                gtk_loop.stop()
            else:
                gtk_loop.call_soon(inner)
                gtk_loop.run()
                print('loop {} stopped'.format(i))
                gtk_loop.stop()
Exemple #2
0
    def test_event_loop_recursion(self, gtk_loop):
        loop_count = 0

        def inner():
            nonlocal loop_count
            i = loop_count
            print('starting loop', loop_count)
            loop_count += 1

            if loop_count == 10:
                print('loop {} stopped'.format(i))
                gtk_loop.stop()
            else:
                gtk_loop.call_soon(inner)
                gtk_loop.run()
                print('loop {} stopped'.format(i))
                gtk_loop.stop()

        gtk_loop.call_soon(inner)
        gtk_loop.run_forever()

        assert loop_count == 10