tidy db resource close
This commit is contained in:
parent
106a487dc5
commit
60c1ace489
|
@ -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):
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue