fix: catch closed connection
This commit is contained in:
parent
d297fa2cef
commit
0768bb4ecf
@ -3,7 +3,7 @@ from copy import deepcopy
|
||||
from datetime import date
|
||||
from json import dump as jdump, load as jload
|
||||
from os import makedirs, remove
|
||||
from os.path import exists, dirname
|
||||
from os.path import dirname, exists
|
||||
from select import select as timedInput
|
||||
from sys import stdin
|
||||
from yaml import safe_load
|
||||
|
||||
@ -43,14 +43,18 @@ class Database:
|
||||
LOGGER.info("Connection was not set, setting...")
|
||||
self.connect()
|
||||
else:
|
||||
with self.conn.cursor() as cursor:
|
||||
try:
|
||||
cursor.execute("SELECT 1;")
|
||||
cursor.fetchall()
|
||||
except:
|
||||
LOGGER.warn(
|
||||
'Connection seem to timed out, reconnecting...')
|
||||
self.connect()
|
||||
try:
|
||||
with self.conn.cursor() as cursor:
|
||||
try:
|
||||
cursor.execute("SELECT 1;")
|
||||
cursor.fetchall()
|
||||
except:
|
||||
LOGGER.warn(
|
||||
'Connection seem to timed out, reconnecting...')
|
||||
self.connect()
|
||||
except:
|
||||
LOGGER.warn('Connection seem to timed out, reconnecting...')
|
||||
self.connect()
|
||||
|
||||
def connectionpersistence(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
|
||||
@ -3,7 +3,7 @@ from flask import Flask, abort, request
|
||||
from flask.json import jsonify
|
||||
from gevent.pywsgi import WSGIServer
|
||||
from os import makedirs
|
||||
from os.path import exists, dirname
|
||||
from os.path import dirname, exists
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user