本文整理汇总了Python中scheduler.Scheduler.add_new_task方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.add_new_task方法的具体用法?Python Scheduler.add_new_task怎么用?Python Scheduler.add_new_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.add_new_task方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_schedule2
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import add_new_task [as 别名]
def test_schedule2(self):
metric_1 = Metric(1, 60, [1, 2, 4, 5, 6, 9, 47, 48, 49, 50])
metric_2 = Metric(2, 60, [1, 2, 4, 5, 6, 9, 47, 48, 49, 50])
metrics = [metric_1, metric_2]
task_1 = Task(1, u'200.0.0.1', u'200.0.0.2', 1, 1800, 0)
task_2 = Task(2, u'200.0.0.1', u'200.0.0.2', 2, 3600, 0)
task_3 = Task(3, u'200.0.0.2', u'200.0.0.1', 1, 2400, 0)
task_4 = Task(4, u'200.0.0.2', u'200.0.0.1', 2, 1440, 0)
task_5 = Task(5, u'200.0.0.2', u'200.0.0.1', 2, 3600, 0)
tasks = [task_1, task_2, task_3, task_4]
scheduler = Scheduler(4, metrics)
scheduler.add_tasks(tasks)
scheduler.print_schedule()
self.assertEqual(1, scheduler.schedules[0].task_id)
self.assertEqual(0, scheduler.schedules[0].start)
self.assertEqual(1, scheduler.schedules[1].task_id)
self.assertEqual(1800, scheduler.schedules[1].start)
self.assertEqual(1, scheduler.schedules[2].task_id)
self.assertEqual(3600, scheduler.schedules[2].start)
self.assertEqual(1, scheduler.schedules[3].task_id)
self.assertEqual(5400, scheduler.schedules[3].start)
self.assertEqual(2, scheduler.schedules[4].task_id)
self.assertEqual(60, scheduler.schedules[4].start)
self.assertEqual(2, scheduler.schedules[5].task_id)
self.assertEqual(3660, scheduler.schedules[5].start)
self.assertEqual(3, scheduler.schedules[6].task_id)
self.assertEqual(120, scheduler.schedules[6].start)
self.assertEqual(3, scheduler.schedules[7].task_id)
self.assertEqual(2400, scheduler.schedules[7].start)
self.assertEqual(3, scheduler.schedules[8].task_id)
self.assertEqual(4800, scheduler.schedules[8].start)
self.assertEqual(4, scheduler.schedules[9].task_id)
self.assertEqual(180, scheduler.schedules[9].start)
self.assertEqual(4, scheduler.schedules[10].task_id)
self.assertEqual(1440, scheduler.schedules[10].start)
self.assertEqual(4, scheduler.schedules[11].task_id)
self.assertEqual(2880, scheduler.schedules[11].start)
self.assertEqual(4, scheduler.schedules[12].task_id)
self.assertEqual(4320, scheduler.schedules[12].start)
self.assertEqual(4, scheduler.schedules[13].task_id)
self.assertEqual(5760, scheduler.schedules[13].start)
scheduler.add_new_task(task_5)
scheduler.print_schedule()
#scheduler.print_table()
scheduler.delete_task(task_2)
scheduler.print_schedule()
scheduler.delete_task(task_3)
scheduler.print_schedule()
#scheduler.print_table()
scheduler.add_new_task(task_3)
scheduler.print_schedule()
示例2: test_basic_schedule1
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import add_new_task [as 别名]
def test_basic_schedule1(self):
task_1 = Task(11, "MPA1", "MPA2", 1, 30, 0)
task_2 = Task(22, "MPA1", "MPA2", 2, 60, 0)
task_3 = Task(33, "MPA2", "MPA1", 1, 40, 0)
task_4 = Task(44, "MPA2", "MPA1", 2, 24, 0)
task_5 = Task(55, "MPA2", "MPA1", 2, 60, 0)
metrics = [self.metric_1, self.metric_2]
scheduler = Scheduler(4, metrics)
tasks = [task_1, task_2, task_3, task_4]
scheduler.add_tasks(tasks)
scheduler.print_schedule()
scheduler.print_table()
self.assertEqual(11, scheduler.schedules[0].task_id)
self.assertEqual(0, scheduler.schedules[0].start)
self.assertEqual(11, scheduler.schedules[1].task_id)
self.assertEqual(30, scheduler.schedules[1].start)
self.assertEqual(11, scheduler.schedules[2].task_id)
self.assertEqual(60, scheduler.schedules[2].start)
self.assertEqual(11, scheduler.schedules[3].task_id)
self.assertEqual(90, scheduler.schedules[3].start)
self.assertEqual(22, scheduler.schedules[4].task_id)
self.assertEqual(1, scheduler.schedules[4].start)
self.assertEqual(22, scheduler.schedules[5].task_id)
self.assertEqual(61, scheduler.schedules[5].start)
self.assertEqual(33, scheduler.schedules[6].task_id)
self.assertEqual(2, scheduler.schedules[6].start)
self.assertEqual(33, scheduler.schedules[7].task_id)
self.assertEqual(40, scheduler.schedules[7].start)
self.assertEqual(33, scheduler.schedules[8].task_id)
self.assertEqual(80, scheduler.schedules[8].start)
self.assertEqual(44, scheduler.schedules[9].task_id)
self.assertEqual(3, scheduler.schedules[9].start)
self.assertEqual(44, scheduler.schedules[10].task_id)
self.assertEqual(24, scheduler.schedules[10].start)
self.assertEqual(44, scheduler.schedules[11].task_id)
self.assertEqual(48, scheduler.schedules[11].start)
self.assertEqual(44, scheduler.schedules[12].task_id)
self.assertEqual(72, scheduler.schedules[12].start)
self.assertEqual(44, scheduler.schedules[13].task_id)
self.assertEqual(96, scheduler.schedules[13].start)
scheduler.add_new_task(task_5)
scheduler.print_schedule()
scheduler.print_table()