Skip to content

Commit

Permalink
Merge pull request #66 from chentex/multi-request-resilience
Browse files Browse the repository at this point in the history
Adds a try..except to avoid errors in mappers
  • Loading branch information
chentex authored Dec 4, 2023
2 parents 033a7a7 + 75ed39c commit 47f6e43
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions backend/app/api/v1/endpoints/cpt/cptJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
router = APIRouter()

products = {
"ocp": ocpMapper,
}
"ocp": ocpMapper,
}


@router.get('/api/cpt/v1/jobs',
summary="Returns a job list from all the products.",
Expand All @@ -37,9 +38,14 @@ async def jobs(start_date: date = Query(None, description="Start date for search
return Response(content=json.dumps({'error': "invalid date format, start_date must be less than end_date"}), status_code=422)

results = pd.DataFrame()
for func in products.values():
df = await func(start_date, end_date)
results = pd.concat([results, df])
for product in products:
try:
df = await products[product](start_date, end_date)
results = pd.concat([results, df])
except ConnectionError:
print("Connection Error in mapper for product " + product)
except:
print("Unknown Error in mapper for product " + product)

response = {
'startDate': start_date.__str__(),
Expand Down

0 comments on commit 47f6e43

Please sign in to comment.