mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
Add exception protection for unexpected conditions during request handling
This commit is contained in:
@ -37,6 +37,7 @@ async def polling_loop():
|
|||||||
raise ValueError("User token must be set to get notifications")
|
raise ValueError("User token must be set to get notifications")
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
headers = {
|
headers = {
|
||||||
"Accept": "application/vnd.github.v3+json",
|
"Accept": "application/vnd.github.v3+json",
|
||||||
"Authorization": f"Bearer {token}"
|
"Authorization": f"Bearer {token}"
|
||||||
@ -81,6 +82,9 @@ async def polling_loop():
|
|||||||
print(f"Failed to fetch notifications. Status code: {response.status}")
|
print(f"Failed to fetch notifications. Status code: {response.status}")
|
||||||
|
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Exception during processing of a notification: {e}")
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
asyncio.run(polling_loop())
|
asyncio.run(polling_loop())
|
||||||
|
Reference in New Issue
Block a user