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


Python Scheduler.is_time方法代码示例

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


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

示例1: consumer_

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import is_time [as 别名]
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,代码行数:29,代码来源:daemon.py

示例2: producer_

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import is_time [as 别名]
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,代码行数:35,代码来源:daemon.py


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