diff --git a/common.py b/common.py index 146ff04..866fa56 100644 --- a/common.py +++ b/common.py @@ -110,6 +110,13 @@ def unmark_user_posted(bot_name, user_id): return cursor.rowcount > 0 # Returns True if a row was deleted +def db_close(): + try: + cursor.close() + conn.close() + except Exception: + pass + # It is not safe to get notifications from "last_id" because some may have been deleted def get_new_notifications(api, bot_name, types=None): diff --git a/feditree.py b/feditree.py index 2a360ff..1e90db6 100644 --- a/feditree.py +++ b/feditree.py @@ -1,7 +1,7 @@ from dotenv import load_dotenv from PIL import Image, ImageFile -from common import get_api, get_new_notifications, list_read, list_append, has_user_posted, mark_user_posted, unmark_user_posted +from common import get_api, get_new_notifications, has_user_posted, mark_user_posted, unmark_user_posted, db_close import datetime import gettext import requests @@ -158,3 +158,5 @@ if os.path.exists(temp_image_name): os.remove(temp_image_name) except Exception: pass + +db_close() \ No newline at end of file