Better error handling

This commit is contained in:
Michel Roux 2020-03-22 17:53:50 +01:00
parent 63d4a722f1
commit a2d691dbf9
2 changed files with 6 additions and 5 deletions

8
app.py
View File

@ -1,5 +1,6 @@
import time from logging import getLogger
from operator import attrgetter, itemgetter from operator import attrgetter, itemgetter
from time import sleep
from flask import redirect, render_template, request, url_for from flask import redirect, render_template, request, url_for
@ -182,6 +183,7 @@ if __name__ == '__main__':
while True: while True:
try: try:
app.run('0.0.0.0', APP_PORT, IS_DEBUG) app.run('0.0.0.0', APP_PORT, IS_DEBUG)
except Exception: except Exception as e:
time.sleep(10) getLogger().exception(e)
sleep(10)
pass pass

View File

@ -10,7 +10,6 @@ from urllib.parse import quote
import requests import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from requests import Timeout
from config import IS_DEBUG, CACHE_TIMEOUT, BLACKLIST_WORDS from config import IS_DEBUG, CACHE_TIMEOUT, BLACKLIST_WORDS
from models import AnimeLink from models import AnimeLink
@ -164,7 +163,7 @@ class Connector(ABC):
output = response.text output = response.text
http_code = response.status_code http_code = response.status_code
except Timeout as e: except requests.Timeout as e:
output = '' output = ''
http_code = 500 http_code = 500
if IS_DEBUG: if IS_DEBUG: