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


Python Scheduler.run方法代码示例

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


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

示例1: run_scheduler

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
def run_scheduler():
    from scheduler import Scheduler
    scheduler = Scheduler(taskdb=get_taskdb(), projectdb=get_projectdb(),
            newtask_queue=newtask_queue, status_queue=status_queue, out_queue=scheduler2fetcher)

    run_in_thread(scheduler.xmlrpc_run, port=scheduler_xmlrpc_port)
    scheduler.run()
开发者ID:7uk0n,项目名称:pyspider,代码行数:9,代码来源:run.py

示例2: scheduler

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
def scheduler(ctx):
    """Run Scheduler."""
    from fulmar.scheduler.projectdb import projectdb
    from fulmar.message_queue import newtask_queue, ready_queue, cron_queue
    from scheduler import Scheduler
    scheduler = Scheduler(newtask_queue, ready_queue, cron_queue, projectdb)
    scheduler.run()
开发者ID:tylderen,项目名称:fulmar,代码行数:9,代码来源:cli.py

示例3: SpiNNaker101Tests

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
class SpiNNaker101Tests(unittest.TestCase):
	"""
	Tests a chip in a very vague way...
	"""
	
	def setUp(self):
		# Test that packets are generated appropriately when distributing with a
		# uniform distribution.
		
		self.scheduler = Scheduler()
		self.system = SpiNNakerSystem(self.scheduler, 50000000)
		
		self.chip = SpiNNaker101( self.scheduler
		                        , self.system
		                        , 4 # injection_buffer_length
		                        , 10 # router_period
		                        , 300000000
		                        , 600000000
		                        , 1 # core_period
		                        , 1.0
		                        , None
		                        )
	
	
	def test_loopback(self):
		it = self.scheduler.run()
		
		# Perform 1000 cycles
		while it.next() < 4001:
			pass
		
		# Should have allowed all but 4 packets which are still in the queue
		self.assertEqual(
			self.chip.traffic_generator.counters["generator_injected_packets"] -
			self.chip.traffic_generator.counters["generator_packets_received"],
			4)
		
		# Should have routed one packet per ten cycles...
		self.assertEqual(self.chip.router.counters["packets_routed"], 400)
	
	
	def test_external(self):
		# Put the chip in a large mesh so stuff ends up there
		self.chip.set_mesh_dimensions(1000,1000)
		
		it = self.scheduler.run()
		
		# Perform 1000 cycles
		while it.next() < 4001:
			pass
		
		# Should have allowed very few packets through
		self.assertTrue(
			self.chip.traffic_generator.counters["generator_injected_packets"] < 10)
		
		# The router should be very frustrated
		self.assertTrue(self.chip.router.counters["router_blocked_cycles"] > 300)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:59,代码来源:tests.py

示例4: run_scheduler

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
def run_scheduler(g=g):
    from scheduler import Scheduler
    scheduler = Scheduler(taskdb=g.taskdb, projectdb=g.projectdb, resultdb=g.resultdb,
            newtask_queue=g.newtask_queue, status_queue=g.status_queue,
            out_queue=g.scheduler2fetcher)
    if g.demo_mode:
        scheduler.INQUEUE_LIMIT = 1000

    run_in_thread(scheduler.xmlrpc_run, port=g.scheduler_xmlrpc_port, bind=g.webui_host)
    scheduler.run()
开发者ID:kelvin007,项目名称:pyspider,代码行数:12,代码来源:run.py

示例5: test_block

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_block(self):
		# Test that packets are not generated when the link is blocked.
		
		scheduler = Scheduler()
		system = SpiNNakerSystem(scheduler, 10)
		
		link = DeadLink(scheduler)
		
		# Uniform generator node
		tg = SpiNNakerTrafficGenerator( scheduler
		                              , system
		                              , 1
		                              , 0.1
		                              , link
		                              , link
		                              )
		tg.set_mesh_dimensions(100,100)
		tg.set_mesh_position(50,50)
		
		it = scheduler.run()
		
		# Perform 1000 cycles
		while it.next() < 2000 and tg.counters["generator_cycles"] < 1000:
			pass
		
		# Should have done 1000 cycles
		self.assertEqual(tg.counters["generator_cycles"], 1000)
		
		# We should have tried to send some number of packets that isn't all the
		# time and not never (well, in theory we might not but hey, if this is going
		# wrong you've got a bad day on your hands).
		self.assertTrue(10 < tg.counters["generator_dropped_packets"] < 1000)
		
		# None should have gone out
		self.assertEqual(tg.counters["generator_injected_packets"], 0)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:37,代码来源:tests.py

示例6: Executor

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
class Executor(object):
	def __init__(self, someprocess=None, logit=True, ticks=sys.maxint):
		super(Executor,self).__init__()
		if someprocess:
			self.process = someprocess
		else:
			if ticks < sys.maxint:
				ticks += 1
			self.process = Scheduler(ticks=ticks, name="")
		self.logit = logit
		self.linker = Linker()

	def schedule(self, components):
		if type(components) is not list:
			components = components['components']

		self.process.send(('activate',components), 'control')
	
	def kill(self, components):
		if type(components) is not list:
			components = components['components']

		self.process.send(('deactivate',components), 'control')

	def build(self, links):
		self.graph = self.linker.link(links)
		self.schedule(self.graph)

	def run(self):
		for _ in self.process.run():
			if self.logit:
				print utils.COLOR.cyan,
				print "\tExecd: ", _,
				print utils.COLOR.white
开发者ID:Mizzlr,项目名称:NetFlux,代码行数:36,代码来源:executor.py

示例7: test_do_now

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [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

示例8: main

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
def main():
    setup_logging()

    credentials = get_credentials()
    if credentials["username"] == "" or credentials["password"] == "":
        logger = logging.getLogger("eo")
        logger.error("The username or password are blank. See code for how to set them. Exiting.")
        exit()

    eo = ElectricObject(username=credentials["username"], password=credentials["password"])

    if len(sys.argv) > 1 and sys.argv[1] == "--once":
        show_a_new_favorite(eo)
        exit()

    scheduler = Scheduler(SCHEDULE, lambda: show_a_new_favorite(eo), schedule_jitter=SCHEDULE_JITTER)
    scheduler.run()
开发者ID:blackmad,项目名称:eo1-projects,代码行数:19,代码来源:eo.py

示例9: test_silistix_link

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_silistix_link(self):
		s = Scheduler()
		sl = SilistixLink(s, 10, 5)
		
		# A simple packet container
		class Packet(object):
			def __init__(self,data,length):
				self.data   = data
				self.length = length
		
		# Initially can send
		self.assertTrue(sl.can_send())
		self.assertFalse(sl.can_receive())
		
		sl.send(Packet(123,2))
		
		# Can't send after sending something
		self.assertFalse(sl.can_send())
		self.assertFalse(sl.can_receive())
		
		it = s.run()
		
		# Can't send or recieve until send delay has elapsed
		while it.next() != 10*2 + 5*1:
			self.assertFalse(sl.can_send())
			self.assertFalse(sl.can_receive())
		
		# Can only recieve once data is stable
		self.assertFalse(sl.can_send())
		self.assertTrue(sl.can_receive())
		
		# Can peek
		self.assertEqual(sl.peek().data, 123)
		self.assertFalse(sl.can_send())
		self.assertTrue(sl.can_receive())
		self.assertEqual(sl.peek().data, 123)
		self.assertFalse(sl.can_send())
		self.assertTrue(sl.can_receive())
		
		# Recieved data is correct
		self.assertEqual(sl.receive().data, 123)
		
		# Can't recieve any more
		self.assertFalse(sl.can_send())
		self.assertFalse(sl.can_receive())
		
		# Can't send or recieve until Acknowledge arrives
		while it.next() != 10*2 + 5*2:
			self.assertFalse(sl.can_send())
			self.assertFalse(sl.can_receive())
		
		# Can send once ack is back
		self.assertTrue(sl.can_send())
		self.assertFalse(sl.can_receive())
		
		# Nothing else got scheduled...
		self.assertRaises(StopIteration, it.next)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:59,代码来源:tests.py

示例10: test_dead_link

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_dead_link(self):
		s = Scheduler()
		dl = DeadLink(s)
		
		# Can't do anything...
		self.assertFalse(dl.can_send())
		self.assertFalse(dl.can_receive())
		
		# Didn't schedule anything
		self.assertRaises(StopIteration, s.run().next)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:12,代码来源:tests.py

示例11: test_buffer_link

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_buffer_link(self):
		s = Scheduler()
		bl = BufferLink(s, 2)
		
		# Can only send
		self.assertTrue(bl.can_send())
		self.assertFalse(bl.can_receive())
		
		bl.send(123)
		
		# Have something to recieve and space left
		self.assertTrue(bl.can_send())
		self.assertTrue(bl.can_receive())
		
		bl.send(456)
		
		# Have something to recieve and no space left
		self.assertFalse(bl.can_send())
		self.assertTrue(bl.can_receive())
		
		# Can peek
		self.assertEqual(bl.peek(), 123)
		self.assertFalse(bl.can_send())
		self.assertTrue(bl.can_receive())
		self.assertEqual(bl.peek(), 123)
		self.assertFalse(bl.can_send())
		self.assertTrue(bl.can_receive())
		
		# In queue order
		self.assertEqual(bl.receive(), 123)
		
		# Still have something to recieve and space left again
		self.assertTrue(bl.can_send())
		self.assertTrue(bl.can_receive())
		
		# Can peek
		self.assertEqual(bl.peek(), 456)
		self.assertTrue(bl.can_send())
		self.assertTrue(bl.can_receive())
		self.assertEqual(bl.peek(), 456)
		self.assertTrue(bl.can_send())
		self.assertTrue(bl.can_receive())
		
		# In queue order
		self.assertEqual(bl.receive(), 456)
		
		# Nothing to recieve and space in buffer
		self.assertTrue(bl.can_send())
		self.assertFalse(bl.can_receive())
		
		# Didn't schedule anything
		self.assertRaises(StopIteration, s.run().next)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:54,代码来源:tests.py

示例12: test_delay_line_link

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_delay_line_link(self):
		s = Scheduler()
		sys = SpiNNakerSystem(s, 1000)
		dll = DelayLineLink(s, 5)
		
		# An example packet
		p = SpiNNakerP2PPacket(sys, "Data", (0,0), 1)
		
		# Can't receive initially but can send
		self.assertFalse(dll.can_receive())
		self.assertTrue(dll.can_send())
		
		it = s.run()
		
		# Does nothing (but keeps scheduling things) if we give it nothing to do
		while it.next() < 100:
			self.assertFalse(dll.can_receive())
			self.assertTrue(dll.can_send())
		# Something happens every cycle...
		self.assertTrue(s.clock == 100)
		
		# Send a packet down the link
		dll.send(p)
		# Can't receive yet
		self.assertFalse(dll.can_receive())
		self.assertTrue(dll.can_send())
		
		# Nothing arrives in four cycles
		while it.next() <= 104:
			self.assertFalse(dll.can_receive())
			self.assertTrue(dll.can_send())
		
		# Something arrives in the fifth cycle
		arrived = False
		while it.next() <= 105:
			arrived = arrived or dll.can_receive()
			self.assertTrue(dll.can_send())
		self.assertTrue(arrived and dll.can_receive())
		
		# Can still receive even if we leave it a moment...
		while it.next() < 150:
			self.assertTrue(dll.can_receive())
			self.assertTrue(dll.can_send())
		
		# Can receive the packet happily
		self.assertEqual(dll.receive(), p)
		self.assertFalse(dll.can_receive())
		self.assertTrue(dll.can_send())
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:50,代码来源:tests.py

示例13: test_normal

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_normal(self):
		# Test that packets are generated appropriately when distributing with a
		# normal distribution.
		
		scheduler = Scheduler()
		system = SpiNNakerSystem(scheduler, 10)
		
		# Share the same link for sending and receiving, that way the module cleans
		# up after itself!
		link = BufferLink(scheduler)
		
		# Uniform generator node
		tg = SpiNNakerTrafficGenerator( scheduler
		                              , system
		                              , 1
		                              , 0.1
		                              , link
		                              , link
		                              , 10
		                              )
		tg.set_mesh_dimensions(100,100)
		tg.set_mesh_position(50,50)
		
		it = scheduler.run()
		
		# Perform 1000 cycles
		while it.next() < 2000 and tg.counters["generator_cycles"] < 1000:
			# We may have a packet
			if link.can_receive():
				# Check the packet is targeted somewhere in the mesh
				packet = link.receive()
				self.assertTrue(all(0 <= dimension < 100 for dimension in packet.destination))
		
		# XXX: Should probably check that distribution is appropriate too but meh...
		
		# Should have done 1000 cycles
		self.assertEqual(tg.counters["generator_cycles"], 1000)
		
		# We should have sent some number of packets that isn't all the time and not
		# never (well, in theory we might not but hey, if this is going wrong you've
		# got a bad day on your hands).
		self.assertTrue(10 < tg.counters["generator_injected_packets"] < 1000)
		
		# None should be dropped
		self.assertEqual(tg.counters["generator_dropped_packets"], 0)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:47,代码来源:tests.py

示例14: test_receive

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [as 别名]
	def test_receive(self):
		# Test that packets are received by the unit
		
		scheduler = Scheduler()
		system = SpiNNakerSystem(scheduler, 10)
		
		# Share the same link for sending and receiving, that way the module cleans
		# up after itself!
		link = BufferLink(scheduler)
		packet = SpiNNakerP2PPacket(system, None, (0,0), 1)
		
		# Uniform generator node
		tg = SpiNNakerTrafficGenerator( scheduler
		                              , system
		                              , 1
		                              , 0
		                              , link
		                              , link
		                              , 10
		                              )
		tg.set_mesh_dimensions(100,100)
		tg.set_mesh_position(50,50)
		
		it = scheduler.run()
		
		# Perform 10 cycles, injecting some packets each time
		while it.next() < 20 and tg.counters["generator_cycles"] < 10:
			self.assertTrue(link.can_send())
			link.send(packet)
		
		# Should have done 10 cycles
		self.assertEqual(tg.counters["generator_cycles"], 10)
		
		# We should have sent no packets
		self.assertEqual(tg.counters["generator_injected_packets"], 0)
		
		# None should be dropped
		self.assertEqual(tg.counters["generator_dropped_packets"], 0)
		
		# Should have received 10 packets
		self.assertEqual(tg.counters["generator_packets_received"], 10)
开发者ID:mossblaser,项目名称:Gollywhomper,代码行数:43,代码来源:tests.py

示例15: test_do_later

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import run [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.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。