def createScheduledEvents(self):

        self.token3: ScheduledCall = Scheduler.schedule_call(delay=ScheduledEventTabPage.DELAY_3_SECS,
                                                             func=self.scheduledMethod,
                                                             repeat=ScheduledEventTabPage.REPEAT)

        self.token6: ScheduledCall = Scheduler.schedule_call(delay=ScheduledEventTabPage.DELAY_3_SECS,
                                                             func=self.scheduledMethod,
                                                             repeat=ScheduledEventTabPage.REPEAT)
예제 #2
0
    def testSchedulingOrder(self):

        #
        # Purposely schedule in wrong order; Scheduler should execute in correct order
        #
        retToken1 = Scheduler.schedule_call(delay=1000, func=TestScheduler.callbackFunction1, repeat=False)
        retToken2 = Scheduler.schedule_call(delay=9000, func=TestScheduler.callbackFunction3, repeat=False)
        retToken3 = Scheduler.schedule_call(delay=5000, func=TestScheduler.callbackFunction2, repeat=False)

        TestScheduler.ourLogger.debug(f"{retToken1}, {retToken2}, {retToken3}")
        TestScheduler.ourLogger.info("Wait long enough so that all tasks will be called in one shot")
        time.sleep(10.0)

        Scheduler.make_scheduled_calls()
        self.assertTrue((TestScheduler.callTime1 < TestScheduler.callTime2) and
                        TestScheduler.callTime2 < TestScheduler.callTime3,
                        "Scheduler called tasks out of order")
예제 #3
0
    def testBasicScheduling(self):

        TestScheduler.ourLogger.info("Test basic scheduling")

        retToken = Scheduler.schedule_call(delay=5000, func=TestScheduler.callbackFunction, repeat=False)

        self.assertIsNotNone(retToken, "I did not get my token")
        nScheduledItems = len(Scheduler.ourScheduledCalls)

        self.assertTrue(nScheduledItems == 1, "Too many scheduled calls")
예제 #4
0
    def testCancelCall(self):

        TestScheduler.ourLogger.info("Test cancel Call")

        retToken = Scheduler.schedule_call(delay=5000, func=TestScheduler.callbackFunction, repeat=False)

        Scheduler.cancel_call(retToken)

        nScheduledItems = len(Scheduler.ourScheduledCalls)

        self.assertTrue(nScheduledItems == 0, "Failed to remove a scheduled calls")
예제 #5
0
    def testMakeScheduledCalls(self):

        TestScheduler.ourLogger.info("Test legacy make_scheduled_calls")

        retToken = Scheduler.schedule_call(delay=0, func=TestScheduler.callbackFunction, repeat=False)

        TestScheduler.ourLogger.info("Task %s scheduled", retToken)

        TestScheduler.ourLogger.info("Sleepy time ...")
        time.sleep(5.0)

        Scheduler.make_scheduled_calls()
        self.assertTrue(TestScheduler.weHaveBeenCalledToken, "The token should have been set, but was not")
예제 #6
0
    def testMakeDueCalls(self):

        TestScheduler.ourLogger.info("Test Scheduler make calls that are due")

        retToken = Scheduler.schedule_call(delay=0, func=TestScheduler.callbackFunction, repeat=False)

        TestScheduler.ourLogger.info("Task %s scheduled", retToken)

        TestScheduler.ourLogger.info("Sleepy time ...")
        time.sleep(10.0)

        TestScheduler.ourLogger.info("We've awakened . . . ")

        timeNow = Scheduler.timestamp()
        untilTime = timeNow + 5000
        aTime = Scheduler.make_due_calls(time_now=timeNow, until_time=untilTime)
        TestScheduler.ourLogger.info("aTime: %s", aTime)

        self.assertTrue(TestScheduler.weHaveBeenCalledToken, "The token should have been set, but was not")