本文整理汇总了Python中models.Feed.for_interval方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.for_interval方法的具体用法?Python Feed.for_interval怎么用?Python Feed.for_interval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.for_interval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_all_feeds
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import for_interval [as 别名]
def update_all_feeds(interval_id):
"""Update all feeds for a specific interval"""
if request.headers.get('X-Appengine-Cron') != 'true':
raise ndb.Return(jsonify_error(message='Not a cron call'))
feeds = Feed.for_interval(interval_id)
success = 0
more = True
cursor = None
futures = []
while more:
feeds_to_fetch, cursor, more = yield feeds.fetch_page_async(100, start_cursor=cursor)
keys = ','.join([x.key.urlsafe() for x in feeds_to_fetch])
if not keys:
continue
futures.append(Queue('poll').add_async(Task(url=url_for('tq_feed_poll'), method='POST', params={'keys': keys})))
success += 1
for future in futures:
yield future
logger.info('queued poll for %d feeds at interval_id=%s', success, interval_id)
raise ndb.Return(jsonify(status='ok'))
示例2: update_all_feeds
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import for_interval [as 别名]
def update_all_feeds(interval_id):
"""Update all feeds for a specific interval"""
if request.headers.get('X-Appengine-Cron') != 'true':
return jsonify_error(message='Not a cron call')
feeds = Feed.for_interval(interval_id)
for feed in feeds:
feed.prepare_request()
errors = 0
success = 0
for feed in feeds:
try:
Entry.update_for_feed(feed, publish=True)
success += 1
except FetchException, e:
errors += 1
pass
except Exception, e:
errors += 1
logger.exception('Failed to update feed:%s' % (feed.feed_url, ))