Skip to content

Commit

Permalink
catch exceptions in threads and restart
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviasculley committed Sep 28, 2023
1 parent efc984f commit d55d30a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sqlite3
import sys
import threading

import traceback
import aiohttp
import pytz
from slack_bolt.app.async_app import AsyncApp
Expand All @@ -30,8 +30,12 @@ async def periodically_check_api():
"""
print("Checking api every hour")
while True:
with sqlite3.connect(DBPATH) as conn:
await check_api(conn)
try:
with sqlite3.connect(DBPATH) as conn:
await check_api(conn)
except Exception: # pylint: disable=broad-except
print(traceback.format_exc())
os._exit(1)
await asyncio.sleep(60 * 60) # 60 minutes x 60 seconds


Expand Down

0 comments on commit d55d30a

Please sign in to comment.