This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# from contextlib import contextmanager
|
||||
from typing import Any, Callable, Dict, TypeVar
|
||||
|
||||
# from psycopg2.errors import UniqueViolation
|
||||
from sqlalchemy import Column, Integer, create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
@@ -18,7 +19,7 @@ REGISTRY: Dict[str, type] = {}
|
||||
# @contextmanager
|
||||
def local_session(src=""):
|
||||
return Session(bind=engine, expire_on_commit=False)
|
||||
|
||||
|
||||
# try:
|
||||
# yield session
|
||||
# session.commit()
|
||||
@@ -60,8 +61,8 @@ class Base(declarative_base()):
|
||||
except Exception as e:
|
||||
print(f"[services.db] Error dict: {e}")
|
||||
return {}
|
||||
|
||||
|
||||
def update(self, values: Dict[str, Any]) -> None:
|
||||
for key, value in values.items():
|
||||
if hasattr(self, key):
|
||||
setattr(self, key, value)
|
||||
for key, value in values.items():
|
||||
if hasattr(self, key):
|
||||
setattr(self, key, value)
|
||||
|
@@ -55,9 +55,9 @@ class RedisCache:
|
||||
|
||||
while True:
|
||||
message = await pubsub.get_message()
|
||||
if message and isinstance(message['data'], (str, bytes, bytearray)):
|
||||
if message and isinstance(message["data"], (str, bytes, bytearray)):
|
||||
try:
|
||||
yield json.loads(message['data'])
|
||||
yield json.loads(message["data"])
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"Error decoding JSON: {e}")
|
||||
await asyncio.sleep(0.1)
|
||||
|
Reference in New Issue
Block a user