Add try except when closing program
This commit is contained in:
@ -165,7 +165,7 @@ def send_to_discord(feed=None) -> None:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
webhook_url: str = str(reader.get_tag(entry.feed.url, "webhook"))
|
webhook_url: str = str(reader.get_tag(entry.feed_url, "webhook"))
|
||||||
except TagNotFoundError:
|
except TagNotFoundError:
|
||||||
logger.error("Tag not found", exc_info=True)
|
logger.error("Tag not found", exc_info=True)
|
||||||
raise
|
raise
|
||||||
|
@ -37,7 +37,7 @@ from fastapi import FastAPI, Form, HTTPException, Request
|
|||||||
from fastapi.responses import FileResponse, HTMLResponse
|
from fastapi.responses import FileResponse, HTMLResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
from reader import EntryCounts, Feed, FeedCounts, ResourceNotFoundError
|
from reader import EntryCounts, Feed, FeedCounts, ReaderError, ResourceNotFoundError
|
||||||
from starlette.templating import _TemplateResponse
|
from starlette.templating import _TemplateResponse
|
||||||
from tomlkit.toml_document import TOMLDocument
|
from tomlkit.toml_document import TOMLDocument
|
||||||
|
|
||||||
@ -254,8 +254,14 @@ def shutdown() -> None:
|
|||||||
It stops the scheduler."""
|
It stops the scheduler."""
|
||||||
scheduler: BackgroundScheduler = BackgroundScheduler()
|
scheduler: BackgroundScheduler = BackgroundScheduler()
|
||||||
scheduler.shutdown()
|
scheduler.shutdown()
|
||||||
|
logger.info("Scheduler stopped.")
|
||||||
|
|
||||||
|
try:
|
||||||
reader.close()
|
reader.close()
|
||||||
|
except ReaderError:
|
||||||
|
logger.error("Error closing reader.", exc_info=True)
|
||||||
|
sys.exit()
|
||||||
|
logger.info("Reader closed.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user