bypass-empty
This commit is contained in:
parent
95e070825f
commit
140e46e9f2
|
@ -3,6 +3,10 @@ from resolvers.model import NotificationReaction, NotificationAuthor, Notificati
|
||||||
from services.db import local_session
|
from services.db import local_session
|
||||||
from services.rediscache import redis
|
from services.rediscache import redis
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(f"[listener.listen_task] ")
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
class ServiceMessage:
|
class ServiceMessage:
|
||||||
|
@ -24,16 +28,17 @@ async def handle_notification(n: ServiceMessage, channel: str):
|
||||||
session.commit()
|
session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
session.rollback()
|
session.rollback()
|
||||||
print(f"[listener.handle_reaction] error: {str(e)}")
|
logger.error(f"[listener.handle_reaction] error: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
async def listen_task(pattern):
|
async def listen_task(pattern):
|
||||||
async for message_data, channel in redis.listen(pattern):
|
async for message_data, channel in redis.listen(pattern):
|
||||||
try:
|
try:
|
||||||
notification_message = ServiceMessage(**message_data)
|
if message_data:
|
||||||
await handle_notification(notification_message, str(channel))
|
notification_message = ServiceMessage(**message_data)
|
||||||
|
await handle_notification(notification_message, str(channel))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[listener.listen_task] Error processing notification: {str(e)}")
|
logger.error(f"Error processing notification: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
async def notifications_worker():
|
async def notifications_worker():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user