当前位置: 首页>>代码示例>>Python>>正文


Python IScheduler.scheduledTimes方法代码示例

本文整理汇总了Python中axiom.iaxiom.IScheduler.scheduledTimes方法的典型用法代码示例。如果您正苦于以下问题:Python IScheduler.scheduledTimes方法的具体用法?Python IScheduler.scheduledTimes怎么用?Python IScheduler.scheduledTimes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在axiom.iaxiom.IScheduler的用法示例。


在下文中一共展示了IScheduler.scheduledTimes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _scheduleMePlease

# 需要导入模块: from axiom.iaxiom import IScheduler [as 别名]
# 或者: from axiom.iaxiom.IScheduler import scheduledTimes [as 别名]
 def _scheduleMePlease(self):
     """
     This queue needs to have its run() method invoked at some point in the
     future.  Tell the dependent scheduler to schedule it if it isn't
     already pending execution.
     """
     sched = IScheduler(self.store)
     if len(list(sched.scheduledTimes(self))) == 0:
         sched.schedule(self, sched.now())
开发者ID:fusionapp,项目名称:mantissa,代码行数:11,代码来源:interstore.py

示例2: _schedule

# 需要导入模块: from axiom.iaxiom import IScheduler [as 别名]
# 或者: from axiom.iaxiom.IScheduler import scheduledTimes [as 别名]
 def _schedule(self, when):
     """
     Ensure that this hook is scheduled to run at or before C{when}.
     """
     sched = IScheduler(self.store)
     for scheduledAt in sched.scheduledTimes(self):
         if when < scheduledAt:
             sched.reschedule(self, scheduledAt, when)
         break
     else:
         sched.schedule(self, when)
开发者ID:twisted,项目名称:axiom,代码行数:13,代码来源:scheduler.py

示例3: test_inspection

# 需要导入模块: from axiom.iaxiom import IScheduler [as 别名]
# 或者: from axiom.iaxiom.IScheduler import scheduledTimes [as 别名]
    def test_inspection(self):
        """
        Test that the L{scheduledTimes} method returns an iterable of all the
        times at which a particular item is scheduled to run.
        """
        now = self.now() + timedelta(seconds=1)
        off = timedelta(seconds=3)
        sch = IScheduler(self.store)
        runnable = TestEvent(store=self.store, name=u'Only event')
        sch.schedule(runnable, now)
        sch.schedule(runnable, now + off)
        sch.schedule(runnable, now + off + off)

        self.assertEquals(
            list(sch.scheduledTimes(runnable)),
            [now, now + off, now + off + off])
开发者ID:ldanielburr,项目名称:axiom,代码行数:18,代码来源:test_scheduler.py

示例4: test_scheduledTimesDuringRun

# 需要导入模块: from axiom.iaxiom import IScheduler [as 别名]
# 或者: from axiom.iaxiom.IScheduler import scheduledTimes [as 别名]
    def test_scheduledTimesDuringRun(self):
        """
        L{Scheduler.scheduledTimes} should not include scheduled times that have
        already triggered.
        """
        futureTimes = []
        scheduler = IScheduler(self.store)
        runner = HookRunner(
            store=self.store,
            hook=lambda self: futureTimes.append(
                list(scheduler.scheduledTimes(self))))

        then = self.now() + timedelta(seconds=1)
        scheduler.schedule(runner, self.now())
        scheduler.schedule(runner, then)
        self.clock.advance(1)
        self.assertEquals(futureTimes, [[then], []])
开发者ID:ldanielburr,项目名称:axiom,代码行数:19,代码来源:test_scheduler.py

示例5: SubStoreSchedulerReentrancy

# 需要导入模块: from axiom.iaxiom import IScheduler [as 别名]
# 或者: from axiom.iaxiom.IScheduler import scheduledTimes [as 别名]
class SubStoreSchedulerReentrancy(TestCase):
    """
    Test re-entrant scheduling calls on an item run by a SubScheduler.
    """
    def setUp(self):
        self.clock = Clock()

        self.dbdir = filepath.FilePath(self.mktemp())
        self.store = Store(self.dbdir)
        self.substoreItem = SubStore.createNew(self.store, ['sub'])
        self.substore = self.substoreItem.open()

        self.scheduler = IScheduler(self.store)
        self.subscheduler = IScheduler(self.substore)

        self.scheduler.callLater = self.clock.callLater
        self.scheduler.now = lambda: Time.fromPOSIXTimestamp(self.clock.seconds())
        self.subscheduler.now = lambda: Time.fromPOSIXTimestamp(self.clock.seconds())

        IService(self.store).startService()


    def tearDown(self):
        return IService(self.store).stopService()


    def _scheduleRunner(self, now, offset):
        scheduledAt = Time.fromPOSIXTimestamp(now + offset)
        rescheduleFor = Time.fromPOSIXTimestamp(now + offset + 10)
        runnable = ScheduleCallingItem(store=self.substore, rescheduleFor=rescheduleFor)
        self.subscheduler.schedule(runnable, scheduledAt)
        return runnable


    def testSchedule(self):
        """
        Test the schedule method, as invoked from the run method of an item
        being run by the subscheduler.
        """
        now = self.clock.seconds()
        runnable = self._scheduleRunner(now, 10)

        self.clock.advance(11)

        self.assertEqual(
            list(self.subscheduler.scheduledTimes(runnable)),
            [Time.fromPOSIXTimestamp(now + 20)])

        hook = self.store.findUnique(
            _SubSchedulerParentHook,
            _SubSchedulerParentHook.subStore == self.substoreItem)

        self.assertEqual(
            list(self.scheduler.scheduledTimes(hook)),
            [Time.fromPOSIXTimestamp(now + 20)])


    def testScheduleWithLaterTimedEvents(self):
        """
        Like L{testSchedule}, but use a SubScheduler which has pre-existing
        TimedEvents which are beyond the new runnable's scheduled time (to
        trigger the reschedule-using code-path in
        _SubSchedulerParentHook._schedule).
        """
        now = self.clock.seconds()
        when = Time.fromPOSIXTimestamp(now + 30)
        null = NullRunnable(store=self.substore)
        self.subscheduler.schedule(null, when)
        runnable = self._scheduleRunner(now, 10)

        self.clock.advance(11)

        self.assertEqual(
            list(self.subscheduler.scheduledTimes(runnable)),
            [Time.fromPOSIXTimestamp(now + 20)])

        self.assertEqual(
            list(self.subscheduler.scheduledTimes(null)),
            [Time.fromPOSIXTimestamp(now + 30)])

        hook = self.store.findUnique(
            _SubSchedulerParentHook,
            _SubSchedulerParentHook.subStore == self.substoreItem)

        self.assertEqual(
            list(self.scheduler.scheduledTimes(hook)),
            [Time.fromPOSIXTimestamp(20)])


    def testScheduleWithEarlierTimedEvents(self):
        """
        Like L{testSchedule}, but use a SubScheduler which has pre-existing
        TimedEvents which are before the new runnable's scheduled time.
        """
        now = self.clock.seconds()
        when = Time.fromPOSIXTimestamp(now + 15)
        null = NullRunnable(store=self.substore)
        self.subscheduler.schedule(null, when)
        runnable = self._scheduleRunner(now, 10)

#.........这里部分代码省略.........
开发者ID:ldanielburr,项目名称:axiom,代码行数:103,代码来源:test_scheduler.py


注:本文中的axiom.iaxiom.IScheduler.scheduledTimes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。