本文整理汇总了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)
示例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)