def __init__(self, test):
        QObject.__init__(self)
        QQmlIncubationController.__init__(self)
        self.test = test
        self.interrupted = False

        # Incubate every 50 milliseconds
        self.startTimer(50)
        self.incubationShouldContinue = VolatileBool(True)
        self.test.assertEqual(self.incubationShouldContinue.get(), True)
class CustomIncubationController(QObject, QQmlIncubationController):
    def __init__(self, test):
        QObject.__init__(self)
        QQmlIncubationController.__init__(self)
        self.test = test
        self.interrupted = False

        # Incubate every 50 milliseconds
        self.startTimer(50)
        self.incubationShouldContinue = VolatileBool(True)
        self.test.assertEqual(self.incubationShouldContinue.get(), True)

    @Slot()
    def interrupter(self):
        if not self.interrupted:
            self.interrupted = True
            self.incubationShouldContinue.set(False)
            self.test.assertEqual(self.incubationShouldContinue.get(), False)
            QTimer.singleShot(0, QGuiApplication.instance().quit)

    def timerEvent(self, ev):
        # Incubate items for 2000 milliseconds, or until the volatile bool is set to false.
        self.incubateWhile(self.incubationShouldContinue, 2000)