• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python scheduler.Scheduler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Executor

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,代码行数:34,代码来源:executor.py


示例2: run_scheduler

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,代码行数:7,代码来源:run.py


示例3: scheduler

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,代码行数:7,代码来源:cli.py


示例4: nda_loop

def nda_loop():
	ndutil.setTimezone()

	ndlCom = NdlCom('nDroid-Executer', '127.0.0.1', 12322)
	ndlCom.doCom('Initiating')

	ndlCom.doCom('Loading Config')
	cnfManager = CnfManager()
	cnfManager.load('./nde.cnf')
	cnfData = cnfManager.getCnfData()

	nsQueue = Queue()
	nsLock = threading.Lock()

	netManager = NetManager()
	netManager.setNdlCom(ndlCom)
	netManager.setNsQueue(nsQueue, nsLock)

	ndlCom.doCom('Starting Threads')
	scheduler = Scheduler([ndlCom, nsQueue, nsLock], 'Scheduler')

	scheduler.start()

	reactor.listenUDP(cnfData['comPort'], netManager)
	ndlCom.doCom('Listening Com Port')
	reactor.run()

	scheduler.join()
开发者ID:jovistar,项目名称:nDroid-Executer,代码行数:28,代码来源:nde.py


示例5: bootstrap_scheduler

    def bootstrap_scheduler(self):
        bootstrapped = False
        try:
            self.save("plugin_modules_library", self._plugin_modules_library)
            Scheduler.clear_locks(self)
            self.scheduler = Scheduler()

            for plugin_info, fn, function_name in self.periodic_tasks:
                meta = fn.will_fn_metadata
                self.add_periodic_task(
                    plugin_info["full_module_name"],
                    plugin_info["name"],
                    function_name,
                    meta["sched_args"],
                    meta["sched_kwargs"],
                    meta["function_name"],
                )
            for plugin_info, fn, function_name in self.random_tasks:
                meta = fn.will_fn_metadata
                self.add_random_tasks(
                    plugin_info["full_module_name"],
                    plugin_info["name"],
                    function_name,
                    meta["start_hour"],
                    meta["end_hour"],
                    meta["day_of_week"],
                    meta["num_times_per_day"]
                )
            bootstrapped = True
        except Exception, e:
            self.startup_error("Error bootstrapping scheduler", e)
开发者ID:AirbornePorcine,项目名称:will,代码行数:31,代码来源:main.py


示例6: consumer_

def consumer_():
    """Consumer thread, tweets the book updates."""
    con_schedule = Scheduler(config.TIMETABLE_TWI)
    if config.BOT_TYPE == 'DesktopBot':
        bot = DesktopBot()
        bot.sign_in(auth.user, auth.password)
    else:
        bot = TwitterAPIBot()
        bot.sign_in()
    while True:
        if con_schedule.is_time():
            book = new_books.get()
            total_len = len(book[0]) + len(book[1]) + 1
            if total_len > 140:
                book = (book[0][:-(total_len - 140)], book[1])
            bot.tweet(book[0] + " " + book[1])
            try:
                print " [ [email protected]%s ] Tweet: %s" % (strftime("%H:%M:%S, %d/%m/%y"),
                                                      (book[0] + " " + book[1]))
            except:
                print " [ [email protected]%s ] Tweet." % strftime("%H:%M:%S, %d/%m/%y")
            with to_mark_lock:
                to_mark.append(book[1])
                to_mark_lock.notify()
            sleep(config.TW_FREQ)
        else:
            sleep(60)
开发者ID:7flying,项目名称:tebores,代码行数:27,代码来源:daemon.py


示例7: bootstrap_scheduler

    def bootstrap_scheduler(self):
        print "Bootstrapping scheduler..."
        bootstrapped = False
        try:

            self.save("plugin_modules_library", self._plugin_modules_library)
            Scheduler.clear_locks(self)
            self.scheduler = Scheduler()

            for plugin_info, fn, function_name in self.periodic_tasks:
                self.add_periodic_task(
                    plugin_info["full_module_name"],
                    plugin_info["name"],
                    function_name,
                    fn.sched_args,
                    fn.sched_kwargs,
                    fn.function_name,
                )
            for plugin_info, fn, function_name in self.random_tasks:
                self.add_random_tasks(
                    plugin_info["full_module_name"],
                    plugin_info["name"],
                    function_name,
                    fn.start_hour,
                    fn.end_hour,
                    fn.day_of_week,
                    fn.num_times_per_day,
                )
            bootstrapped = True
        except Exception, e:
            self.startup_error("Error bootstrapping scheduler", e)
开发者ID:Bengt,项目名称:will,代码行数:31,代码来源:main.py


示例8: test_block

	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,代码行数:35,代码来源:tests.py


示例9: main

def main():
    auth = Conf("bot.conf").getSection("auth")
    if not "login" in auth or not "password" in auth:
        print("Configuration not entirely filled.. Try again.")
        sys.exit(1)
    xmpp = Jarvis(auth["login"], auth["password"], auth["room"])
    xmpp.ssl_version = ssl.PROTOCOL_SSLv3
    xmpp.register_plugin('xep_0030') # Service Discovery
    xmpp.register_plugin('xep_0199')
    xmpp.register_plugin('xep_0085') # status message
    xmpp.register_plugin('xep_0071') # Xhtml
    xmpp.register_plugin('xep_0045') # multi user chan
    xmpp.register_plugin('xep_0203')  # XMPP Delayed messages
    xmpp.register_plugin('xep_0249')  # XMPP direct MUC invites
    e = Events(xmpp)
    e.start()
    s = Scheduler(xmpp)
    s.start()
    t = ClientTask(xmpp)
    t.start()

    if xmpp.connect():
        xmpp.process(block=True)
    else:
        print('Unable to connect')
开发者ID:steven-martins,项目名称:Jarvis,代码行数:25,代码来源:main.py


示例10: save

 def save(self, args):
     if args["oldName"] == "":
         key = args["name"]
         av = Availability()
     else:
         key = args["oldName"]
         av = Availability.find(self.env.get_db_cnx(), key)
     av.name = args["name"]
     av.validFrom = args["validFrom"]
     av.validUntil = args["validUntil"]
     av.resources = args["resources"]
     av.weekdays = ""
     self.appendWeekdays(av, args, "1")
     self.appendWeekdays(av, args, "2")
     self.appendWeekdays(av, args, "3")
     self.appendWeekdays(av, args, "4")
     self.appendWeekdays(av, args, "5")
     self.appendWeekdays(av, args, "6")
     self.appendWeekdays(av, args, "0")
     av.workFrom = args["workFrom"]
     av.workUntil = args["workUntil"]
     av.save(self.env.get_db_cnx(), key)
     scheduler = Scheduler()
     scheduler.schedule(self.env, self.config);
     return 'admin_availability.html', {"availabilities" : self.availabilities(), "view": "list"}
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:25,代码来源:admin.py


示例11: test_scheduler_bind_config

    def test_scheduler_bind_config(self):
        scheduler = Scheduler()

        config = Config('''
                        timer test_timer {
                            interval: 2
                            event: test_timer_event
                        }

                        process demo_add {
                            trigger: op1_value, op2_value
                            script: {
                                sum := op1_value + op2_value
                                emit sum_value(sum)
                            }
                        }

                        process gen_op1 {
                            trigger: test_timer_event
                            script: {
                                emit op1_value(2)
                            }
                        }

                        process gen_op2 {
                            trigger: test_timer_event
                            script: {
                                emit op2_value(3)
                            }
                        }''')

        scheduler.bind(config)
开发者ID:sonologic,项目名称:thermo2,代码行数:32,代码来源:test_scheduler.py


示例12: producer_

def producer_():
    """Producer thread, checks the book pages."""
    pro_schedule = Scheduler(config.TIMETABLE_SCRA)
    crawlers = []
    for subcrawler in BookCrawler.__subclasses__():
        crawlers.append(BookCrawler.factory(subcrawler.__name__))
    while True:
        if pro_schedule.is_time():
            for crawler in crawlers:
                books = crawler.get_books()
                for book in books.keys():
                    if is_new_book(book):
                        # url of web page, book name, book url
                        insert_book(crawler.get_url(), books[book], book)
                        try:
                            print " [ [email protected]%s ] New book: %s" % (strftime("%H:%M:%S, %d/%m/%y"),
                                                                     books[book] + \
                                                                     " - " + \
                                                                     crawler.get_url() + \
                                                                     book)
                        except:
                            print " [ [email protected]%s ] New book." % strftime("%H:%M:%S, %d/%m/%y")
                        new_books.put((books[book], crawler.get_url() + book))
                        with to_mark_lock:
                            while not to_mark:
                                to_mark_lock.wait()
                            mark = to_mark.pop(0)
                            mark_tweeted(mark)
                        sleep(1)
            # Wait
            sleep(config.S_FREQ)
        else:
            sleep(60)
开发者ID:7flying,项目名称:tebores,代码行数:33,代码来源:daemon.py


示例13: test_do_now

	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,代码行数:8,代码来源:tests.py


示例14: SpiNNaker101Tests

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,代码行数:57,代码来源:tests.py


示例15: test_silistix_link

	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,代码行数:57,代码来源:tests.py


示例16: cmd_done

 def cmd_done(cls, data):
     #print(data)
     agent_id = data['agent_id']
     cmd_spec = cls.running_cmds[agent_id]
     cmd_spec['exitcode'] = data['exitcode']
     cmd_spec['errmsg']   = data['errmsg']
     del cls.running_cmds[agent_id]
     cls.idle_agents.add(agent_id)
     Scheduler.wake(cls.agent_visitor[agent_id])
开发者ID:wehu,项目名称:pydv,代码行数:9,代码来源:job.py


示例17: test_start_stop

    def test_start_stop(self):
        cp = Scheduler(
            [("odd_year", "* * * * * *")],
            [("even_year", "* * * * * */2")],
            start_year=1990, stop_year=1999
        )

        self.assertEqual(cp.get_matching_rules(datetime(1991, 12, 19, 18, 31))[0], "odd_year")
        self.assertEqual(cp.get_matching_rules(datetime(1992, 12, 19, 18, 31))[0], "even_year")
        self.assertEqual(cp.get_matching_rules(datetime(2000, 12, 19, 18, 31)), [])
开发者ID:pycronius,项目名称:pycronius,代码行数:10,代码来源:tests.py


示例18: test_dead_link

	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,代码行数:10,代码来源:tests.py


示例19: run_scheduler

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,代码行数:10,代码来源:run.py


示例20: test_scheduler_insert_event

 def test_scheduler_insert_event(self):
     scheduler = Scheduler()
     
     t = time()
     while time() < t+1:
         self.assertEqual(scheduler.schedule(),'idle')
         sleep(0.05)
  
     event = Event(time(), 'test_event')
     self.assertEqual(scheduler.schedule([event]),event)
开发者ID:sonologic,项目名称:thermo2,代码行数:10,代码来源:test_scheduler.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python schema.get_schema函数代码示例发布时间:2022-05-27
下一篇:
Python utils.OccurrenceReplacer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap