def get_time_totals_from_pond(timeallocation, start, end, too, recur=0):
"""
Pond queries are too slow with large proposals and time out, this hack splits the query
when a timeout occurs
"""
if recur > 3:
raise RecursionError('Pond is timing out, too much recursion.')
total = 0
try:
total += query_pond(
timeallocation.proposal.id, start, end, timeallocation.telescope_class, timeallocation.instrument_name, too
)
except requests.HTTPError:
logger.warning('We got a pond inception. Splitting further.')
for start, end in split_time(start, end, 4):
total += get_time_totals_from_pond(timeallocation, start, end, too, recur=recur + 1)
return total
评论列表
文章目录