From 140e46e9f252f4773f98868c5f4def3ceef677f6 Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 23 Jan 2024 11:44:37 +0300 Subject: [PATCH] bypass-empty --- resolvers/listener.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/resolvers/listener.py b/resolvers/listener.py index 5487c85..71c1eaf 100644 --- a/resolvers/listener.py +++ b/resolvers/listener.py @@ -3,6 +3,10 @@ from resolvers.model import NotificationReaction, NotificationAuthor, Notificati from services.db import local_session from services.rediscache import redis import asyncio +import logging + +logger = logging.getLogger(f"[listener.listen_task] ") +logger.setLevel(logging.DEBUG) class ServiceMessage: @@ -24,16 +28,17 @@ async def handle_notification(n: ServiceMessage, channel: str): session.commit() except Exception as e: 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 for message_data, channel in redis.listen(pattern): try: - notification_message = ServiceMessage(**message_data) - await handle_notification(notification_message, str(channel)) + if message_data: + notification_message = ServiceMessage(**message_data) + await handle_notification(notification_message, str(channel)) 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():