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


Python Scheduler.do_now方法代码示例

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


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

示例1: test_do_now

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import do_now [as 别名]
	def test_do_now(self):
		# If I schedule something now, it happens in the zeroth clock and then it
		# exits
		s = Scheduler()
		s.do_now((lambda: None))
		iterator = s.run()
		self.assertEqual(iterator.next(), 0)
		self.assertRaises(StopIteration, iterator.next)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:10,代码来源:tests.py

示例2: test_do_later

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import do_now [as 别名]
	def test_do_later(self):
		# If I schedule something later, it happens after something which happens
		# now
		
		now_called   = [False]
		def for_now(): now_called[0] = True
		later_called = [False]
		def for_later(): later_called[0] = True
		much_later_called = [False]
		def for_much_later(): much_later_called[0] = True
		
		
		s = Scheduler()
		s.do_now(for_now)
		s.do_later(for_later)
		s.do_later(for_much_later, 10)
		
		iterator = s.run()
		
		self.assertTrue(    not now_called[0]
		                and not later_called[0]
		                and not much_later_called[0])
		
		self.assertEqual(iterator.next(), 0)
		self.assertTrue(        now_called[0]
		                and not later_called[0]
		                and not much_later_called[0])
		
		self.assertEqual(iterator.next(), 0)
		self.assertTrue(        now_called[0]
		                and     later_called[0]
		                and not much_later_called[0])
		
		self.assertEqual(iterator.next(), 10)
		self.assertTrue(        now_called[0]
		                and     later_called[0]
		                and     much_later_called[0])
		
		self.assertRaises(StopIteration, iterator.next)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:41,代码来源:tests.py


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