mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-24 06:18:08 -05:00
Error handling in promote.get_scheduled
Aggressively catches and logs exceptions inside the campaign loop in get_scheduled. This change will allow make_daily_promotions to skip over campaigns with corrupt data and still launch the others. Note: We might want to consider passing the list of errored campaigns back up to the calling function so they can be handled more noisily there.
This commit is contained in:
@@ -652,9 +652,17 @@ def accepted_campaigns(offset=0):
|
||||
|
||||
def get_scheduled(offset=0):
|
||||
by_sr = {}
|
||||
failed = []
|
||||
for l, campaign, weight in accepted_campaigns(offset=offset):
|
||||
if authorize.is_charged_transaction(campaign.trans_id, campaign._id):
|
||||
by_sr.setdefault(campaign.sr_name, []).append((l, weight))
|
||||
try:
|
||||
if authorize.is_charged_transaction(campaign.trans_id, campaign._id):
|
||||
by_sr.setdefault(campaign.sr_name, []).append((l, weight))
|
||||
except Exception, e: # could happen if campaign things have corrupt data
|
||||
failed.append((campaign._id, e))
|
||||
if failed:
|
||||
err_msgs = ["camp id: %d, reason: %r" % (f[0], f[1]) for f in failed]
|
||||
g.log.error("%d accepted campaign not included in schedule:\n%s" %
|
||||
(len(failed), "\n".join(err_msgs)))
|
||||
return by_sr
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user