當前位置: 首頁>>代碼示例>>Python>>正文


Python schedule.every方法代碼示例

本文整理匯總了Python中schedule.every方法的典型用法代碼示例。如果您正苦於以下問題:Python schedule.every方法的具體用法?Python schedule.every怎麽用?Python schedule.every使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在schedule的用法示例。


在下文中一共展示了schedule.every方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: schedule_with_delay

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def schedule_with_delay(self):
        for task in self.tasks:
            interval = task.get('interval')
            schedule.every(interval).minutes.do(self.schedule_task_with_lock, task)
        while True:
            schedule.run_pending()
            time.sleep(1) 
開發者ID:SpiderClub,項目名稱:haipproxy,代碼行數:9,代碼來源:scheduler.py

示例2: prepare_jobs

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def prepare_jobs(self, jobs):
        suffixed_names = {
            'week': 'weekly',
            'day': 'daily',
            'hour': 'hourly',
            'minute': 'minutes',
            'second': 'seconds',
        }
        for job in jobs:
            if not job.enabled:
                continue

            interval_name = job.time_unit.lower()
            if job.interval > 0: # There can't be a job less than 0 (0 minutes? 0 seconds?)
                plural_interval_name = interval_name + 's'
                d = getattr(schedule.every(job.interval), plural_interval_name)
                d.do(self.run_job, job)
                Log.info("  Loading %s job: %s.", suffixed_names[interval_name], job.name)
            elif interval_name == 'day':
                schedule.every().day.at(job.at_time).do(self.run_job, job)
                Log.info("  Loading time-based job: " + job.name)
            else:
                d = getattr(schedule.every(), interval_name)
                d.do(self.run_job, job)
                Log.info("  Loading %s job: %s", interval_name, job.name) 
開發者ID:mayaculpa,項目名稱:hapi,代碼行數:27,代碼來源:smart_module.py

示例3: _run

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def _run(self):
        if self.args.run_mode == 'job':
            schedule.every().day.at('00:00').do(self._build_report)
            while True:
                schedule.run_pending()
                time.sleep(1)
        else:
            self._build_report(self.args.date) 
開發者ID:MycroftAI,項目名稱:selene-backend,代碼行數:10,代碼來源:daily_report.py

示例4: go_click

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def go_click(self):
        self.save_settings()

        schedule.clear()
        if config['schedule']['schedule_time']:
            schedule.every().day.at(config['schedule']['schedule_time']).do(self.start_click, sched_task=True)
        else:
            schedule.every().day.at("08:00").do(self.start_click)

        try:
            self.task_monitor.isAlive()
        except AttributeError:
            self.task_monitor = threading.Thread(target=self.run_monitor)
        else:
            if not self.task_monitor.isAlive():
                self.task_monitor = threading.Thread(target=self.run_monitor)
        finally:
            if not self.task_monitor.isAlive():
                self.task_monitor.setDaemon(True)
                self.task_monitor.start()

        app.log('當前賬號: %s' % config['dingtalk']['username'])
        app.log('等待下次學習時間: %s' % schedule.next_run()) 
開發者ID:zodiac182,項目名稱:autoxuexi,代碼行數:25,代碼來源:xuexi.py

示例5: __init__

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def __init__(self, port="5550"):
        self.__bind_addr = "tcp://*:%s" % port
        app.logger.info("Bind address: " + self.__bind_addr)

        self.__relay_lock = threading.Lock()

        self.__db = GarageDb(app.instance_path, app.resource_path)

        # Get initial reed state and subscribe to events
        GPIO.setup(app.config['REED_PIN'], GPIO.IN)
        GPIO.add_event_detect(app.config['REED_PIN'], GPIO.BOTH, callback=self.door_opened_or_closed)
        self.__door_state = None                            # 1 for open, 0 for closed, None for uninitialized
        self.door_opened_or_closed(app.config['REED_PIN'])  # force update

        # Set up warning timer if there's a setting
        if app.config['DOOR_OPEN_WARNING_TIME']:
            app.logger.info('Starting schedule to check door at {0}...'.format(app.config['DOOR_OPEN_WARNING_TIME']))
            schedule.every().day.at(app.config['DOOR_OPEN_WARNING_TIME']).do(self.check_door_open_for_warning)
            t = Thread(target=self.run_schedule)
            t.start()
        else:
            app.logger.info('No schedule to run.') 
開發者ID:nathanpjones,項目名稱:GaragePi,代碼行數:24,代碼來源:controller.py

示例6: set_schedule

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def set_schedule(time):
    schedule.every().monday.at(time).do(sync_trades)
    schedule.every().tuesday.at(time).do(sync_trades)
    schedule.every().wednesday.at(time).do(sync_trades)
    schedule.every().thursday.at(time).do(sync_trades)
    schedule.every().friday.at(time).do(sync_trades) 
開發者ID:chrism2671,項目名稱:PyTrendFollow,代碼行數:8,代碼來源:scheduler.py

示例7: _clean_single_schedule

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def _clean_single_schedule(cls, check, schedule_dict):
        if not isinstance(schedule_dict, dict):
            raise ConfigurationError(
                'Check {0} has invalid schedule configuration: {1}'
                .format(check['name'], schedule_dict),
            )
        try:
            every = schedule_dict['every']
        except KeyError:
            raise ConfigurationError(
                "Check {0} has invalid schedule format: {1}"
                .format(check['name'], schedule_dict)
            )
        if isinstance(every, six.string_types):
            # "every: day" shortcut
            unit, every = every, 1
        else:
            unit = schedule_dict.get('unit')
        unit = cls._clean_unit(check, unit)
        at = cls._clean_at(check, schedule_dict.get('at'))
        rule = TimelineRule(every, unit, at)
        logger.debug('Parsed schedule "%r" to %r', schedule_dict, rule)
        return rule 
開發者ID:kibitzr,項目名稱:kibitzr,代碼行數:25,代碼來源:timeline.py

示例8: handle

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def handle(self, args):
        logger = IngestLogger()
        logger.info(
            "Starting Baleen v{} ingestion service every hour.".format(baleen.get_version())
        )

        schedule.every().hour.do(partial(self.ingest, args))

        while True:
            try:
                schedule.run_pending()
                time.sleep(1)
            except (KeyboardInterrupt, SystemExit):
                logger.info("Graceful shutdown of Baleen ingestion service.")
                return ""
            except Exception as e:
                logger.critical(str(e))
                return str(e) 
開發者ID:DistrictDataLabs,項目名稱:baleen,代碼行數:20,代碼來源:run.py

示例9: __init__

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def __init__(self):
        md = MalwareFeedDescription(
            module_name="MalShare",
            interval = schedule.every().day.at("04:00"),
            description="Feed from MalShare of Daily files",
            authors=["Silas Cutler"],
            version="0.2"
        )
        MalwareFeed.__init__(self, md)
        self.parse_settings()

        self.url_daily_list = "https://malshare.com/daily/malshare.current.sha256.txt"
        self.url_download = "https://malshare.com/api.php?api_key=%s&action=getfile&hash=%s"
        self.url_sources = "https://malshare.com/api.php?api_key=%s&action=getsources"

        # Settings 
開發者ID:silascutler,項目名稱:MalPipe,代碼行數:18,代碼來源:MalShare.py

示例10: handle

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def handle(self, *args, **kwargs):

        logger.info("%s - starting jobs schedule" % (__name__))
            
        try:
            '''            
            schedule.every().hour.do(job_update_entities)
            schedule.every().hour.do(job_update_clients)
            schedule.every().hour.do(job_update_checks)
            schedule.every().hour.do(job_update_trends)
            #schedule.every(10).minutes.do(job_update_events)
            '''
            
            schedule.every(settings.CACHE_ENTITY_TTL).seconds.do(job_update_entities)
            schedule.every(settings.CACHE_CLIENT_TTL).seconds.do(job_update_clients)
            schedule.every(settings.CACHE_TRENDS_TTL).seconds.do(job_update_trends)
            
            
            while True:
                schedule.run_pending()
                sleep(1)

        except KeyboardInterrupt:
            logger.info("%s - user signal exit!" % (__name__))
            exit(0) 
開發者ID:ilavender,項目名稱:sensu_drive,代碼行數:27,代碼來源:jobs.py

示例11: user_callback

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def user_callback(ch, method, properties, body):
    user_json = body.decode()
    user_dict = json.loads(user_json)

    r.set("User:{}".format(user_dict["email"]), user_json)

    schedule.every(periods[user_dict['period']]).days.at("10:00").do(
        sub_ch.basic_publish, exchange='work',
        routing_key=SCHEDULE_NOTIFIER_QUEUE, body=user_dict["email"])

    for s in user_dict['subscriptions'].keys():
        for g in user_dict['subscriptions'][s]:
            sub_ch.basic_publish(exchange='work', routing_key=funcs[s], body=g)
            schedule.every(periods[user_dict['period']]).days.at("10:00").do(
                sub_ch.basic_publish,
                exchange='work',
                routing_key=funcs[s],
                body=g
            ) 
開發者ID:alirizakeles,項目名稱:ab-2018,代碼行數:21,代碼來源:sched.py

示例12: test_every

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def test_every(dummy_bus: lightbus.path.BusPath, event_loop):
    calls = 0

    @dummy_bus.client.every(seconds=0.001)
    async def test_coroutine():
        nonlocal calls
        while True:
            calls += 1
            if calls == 5:
                raise Exception("Intentional exception: stopping lightbus dummy bus from running")
            await asyncio.sleep(0.001)

    # SystemExit raised because test_coroutine throws an exception
    dummy_bus.client.run_forever()

    assert dummy_bus.client.exit_code

    assert calls == 5 
開發者ID:adamcharnock,項目名稱:lightbus,代碼行數:20,代碼來源:test_bus_client_unit.py

示例13: test_schedule

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def test_schedule(dummy_bus: lightbus.path.BusPath):
    import schedule

    calls = 0

    # TODO: This kind of 'throw exception to stop bus' hackery in the tests can be cleaned up
    @dummy_bus.client.schedule(schedule.every(0.001).seconds)
    async def test_coroutine():
        nonlocal calls
        while True:
            calls += 1
            if calls == 5:
                raise Exception("Intentional exception: stopping lightbus dummy bus from running")
            await asyncio.sleep(0.001)

    dummy_bus.client.run_forever()

    assert dummy_bus.client.exit_code

    assert calls == 5 
開發者ID:adamcharnock,項目名稱:lightbus,代碼行數:22,代碼來源:test_bus_client_unit.py

示例14: test_call_on_schedule_async

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def test_call_on_schedule_async(run_for):
    import schedule

    await_count = 0

    async def cb():
        nonlocal await_count
        await_count += 1

    await run_for(
        coroutine=call_on_schedule(
            callback=cb, schedule=schedule.every(0.1).seconds, also_run_immediately=False
        ),
        seconds=0.25,
    )
    assert await_count == 2 
開發者ID:adamcharnock,項目名稱:lightbus,代碼行數:18,代碼來源:test_async_tools.py

示例15: generate_memory_schedule

# 需要導入模塊: import schedule [as 別名]
# 或者: from schedule import every [as 別名]
def generate_memory_schedule(schedulelist, isforupdate=False):

            print "##### Generating Memory Schedule."
            now = datetime.datetime.now()
            now = now.replace(year=1900, month=1, day=1)
            pseudo_cache = pseudo_channel.get_daily_schedule_cache_as_json()
            prev_end_time_to_watch_for = None
            if pseudo_channel.USE_OVERRIDE_CACHE and isforupdate:
                for cached_item in pseudo_cache:
                    prev_start_time = datetime.datetime.strptime(cached_item[8], "%I:%M:%S %p")
                    try:
                        prev_end_time = datetime.datetime.strptime(cached_item[9], '%Y-%m-%d %H:%M:%S.%f')
                    except ValueError:
                        prev_end_time = datetime.datetime.strptime(cached_item[9], '%Y-%m-%d %H:%M:%S')
                    """If update time is in between the prev media start / stop then there is overlap"""
                    if prev_start_time < now and prev_end_time > now:
                        try:
                            print "+++++ It looks like there is update schedule overlap", cached_item[3]
                        except:
                            pass
                        prev_end_time_to_watch_for = prev_end_time
            for item in schedulelist:
                trans_time = datetime.datetime.strptime(item[8], "%I:%M:%S %p").strftime("%H:%M")
                new_start_time = datetime.datetime.strptime(item[8], "%I:%M:%S %p")
                if prev_end_time_to_watch_for == None:
                    schedule.every().day.at(trans_time).do(job_that_executes_once, item, schedulelist).tag('daily-tasks')
                else:
                    """If prev end time is more then the start time of this media, skip it"""
                    if prev_end_time_to_watch_for > new_start_time:
                        try:
                            print "Skipping scheduling item do to cached overlap.", item[3]
                        except:
                            pass
                        continue
                    else:
                        schedule.every().day.at(trans_time).do(job_that_executes_once, item, schedulelist).tag('daily-tasks')
            print "+++++ Done." 
開發者ID:justinemter,項目名稱:pseudo-channel,代碼行數:39,代碼來源:PseudoChannel.py


注:本文中的schedule.every方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。