dev (#3080)
* fix(chalice): fixed unprocessed_sessions.py * refactor(chalice): refactored favorite sessions * fix(chalice): fixed errors handing issue
This commit is contained in:
parent
83f8b67f74
commit
84771542a6
5 changed files with 18 additions and 17 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
|
||||
from chalicelib.core import sessions, assist
|
||||
from chalicelib.core import assist
|
||||
from chalicelib.core.sessions import sessions
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ class ClickHouseClient:
|
|||
keys = tuple(x for x, y in results[1])
|
||||
return [dict(zip(keys, i)) for i in results[0]]
|
||||
except Exception as err:
|
||||
logger.error("--------- CH EXCEPTION -----------")
|
||||
logger.error(err)
|
||||
logger.error("--------- CH EXCEPTION -----------", exc_info=err)
|
||||
logger.error("--------- CH QUERY EXCEPTION -----------")
|
||||
logger.error(self.format(query=query, parameters=parameters)
|
||||
.replace('\n', '\\n')
|
||||
|
|
|
|||
|
|
@ -108,14 +108,14 @@ def make_pool():
|
|||
try:
|
||||
CH_pool.close_all()
|
||||
except Exception as error:
|
||||
logger.error("Error while closing all connexions to CH", error)
|
||||
logger.error("Error while closing all connexions to CH", exc_info=error)
|
||||
try:
|
||||
CH_pool = ClickHouseConnectionPool(min_size=config("CH_MINCONN", cast=int, default=4),
|
||||
max_size=config("CH_MAXCONN", cast=int, default=8))
|
||||
if CH_pool is not None:
|
||||
logger.info("Connection pool created successfully for CH")
|
||||
except ConnectionError as error:
|
||||
logger.error("Error while connecting to CH", error)
|
||||
logger.error("Error while connecting to CH", exc_info=error)
|
||||
if RETRY < RETRY_MAX:
|
||||
RETRY += 1
|
||||
logger.info(f"waiting for {RETRY_INTERVAL}s before retry n°{RETRY}")
|
||||
|
|
@ -174,4 +174,4 @@ async def terminate():
|
|||
CH_pool.close_all()
|
||||
logger.info("Closed all connexions to CH")
|
||||
except Exception as error:
|
||||
logger.error("Error while closing all connexions to CH", error)
|
||||
logger.error("Error while closing all connexions to CH", exc_info=error)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ def make_pool():
|
|||
try:
|
||||
postgreSQL_pool.closeall()
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
logger.error("Error while closing all connexions to PostgreSQL", error)
|
||||
logger.error("Error while closing all connexions to PostgreSQL", exc_info=error)
|
||||
try:
|
||||
postgreSQL_pool = ORThreadedConnectionPool(config("PG_MINCONN", cast=int, default=4),
|
||||
config("PG_MAXCONN", cast=int, default=8),
|
||||
|
|
@ -70,7 +70,7 @@ def make_pool():
|
|||
if postgreSQL_pool is not None:
|
||||
logger.info("Connection pool created successfully")
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
logger.error("Error while connecting to PostgreSQL", error)
|
||||
logger.error("Error while connecting to PostgreSQL", exc_info=error)
|
||||
if RETRY < RETRY_MAX:
|
||||
RETRY += 1
|
||||
logger.info(f"waiting for {RETRY_INTERVAL}s before retry n°{RETRY}")
|
||||
|
|
@ -123,7 +123,7 @@ class PostgresClient:
|
|||
if not self.use_pool or self.long_query or self.unlimited_query:
|
||||
self.connection.close()
|
||||
except Exception as error:
|
||||
logger.error("Error while committing/closing PG-connection", error)
|
||||
logger.error("Error while committing/closing PG-connection", exc_info=error)
|
||||
if str(error) == "connection already closed" \
|
||||
and self.use_pool \
|
||||
and not self.long_query \
|
||||
|
|
@ -150,7 +150,7 @@ class PostgresClient:
|
|||
try:
|
||||
self.connection.rollback()
|
||||
except psycopg2.InterfaceError as e:
|
||||
logger.error("!!! Error while rollbacking connection", e)
|
||||
logger.error("!!! Error while rollbacking connection", exc_info=e)
|
||||
logger.error("!!! Trying to recreate the cursor")
|
||||
self.recreate_cursor()
|
||||
raise error
|
||||
|
|
@ -161,11 +161,11 @@ class PostgresClient:
|
|||
try:
|
||||
self.connection.rollback()
|
||||
except Exception as error:
|
||||
logger.error("Error while rollbacking connection for recreation", error)
|
||||
logger.error("Error while rollbacking connection for recreation", exc_info=error)
|
||||
try:
|
||||
self.cursor.close()
|
||||
except Exception as error:
|
||||
logger.error("Error while closing cursor for recreation", error)
|
||||
logger.error("Error while closing cursor for recreation", exc_info=error)
|
||||
self.cursor = None
|
||||
return self.__enter__()
|
||||
|
||||
|
|
@ -183,4 +183,4 @@ async def terminate():
|
|||
postgreSQL_pool.closeall()
|
||||
logger.info("Closed all connexions to PostgreSQL")
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
logger.error("Error while closing all connexions to PostgreSQL", error)
|
||||
logger.error("Error while closing all connexions to PostgreSQL", exc_info=error)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ import logging
|
|||
|
||||
from decouple import config
|
||||
|
||||
from chalicelib.utils import ch_client, exp_ch_helper
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
import schemas
|
||||
from chalicelib.core.sessions import sessions_mobs, sessions_devtool
|
||||
from chalicelib.core.sessions.sessions_favorite import *
|
||||
from chalicelib.core.sessions.sessions_favorite import add_favorite_session, remove_favorite_session, \
|
||||
favorite_session_exists
|
||||
from chalicelib.utils import ch_client, exp_ch_helper
|
||||
from chalicelib.utils.storage import extra
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
_add_favorite_session = add_favorite_session
|
||||
_remove_favorite_session = remove_favorite_session
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue