fix: minor bug fix
Some checks failed
Build Worker Base and Application Images / deploy-stack (push) Blocked by required conditions
Build Worker Base and Application Images / check-base-changes (push) Successful in 7s
Build Worker Base and Application Images / build-base (push) Successful in 4m44s
Build Worker Base and Application Images / build-docker (push) Has been cancelled

This commit is contained in:
ziesorx 2025-09-25 01:20:07 +07:00
parent 2eba1f94ea
commit 67096d4141
2 changed files with 17 additions and 2 deletions

View file

@ -99,11 +99,13 @@ class LicensePlateManager:
async def _listen_for_messages(self): async def _listen_for_messages(self):
"""Listen for messages on the license_results channel.""" """Listen for messages on the license_results channel."""
listen_generator = None
try: try:
if not self.pubsub: if not self.pubsub:
return return
async for message in self.pubsub.listen(): listen_generator = self.pubsub.listen()
async for message in listen_generator:
if message['type'] == 'message': if message['type'] == 'message':
try: try:
# Log the raw message from Redis channel # Log the raw message from Redis channel
@ -121,8 +123,20 @@ class LicensePlateManager:
except asyncio.CancelledError: except asyncio.CancelledError:
logger.info("License plate subscription task cancelled") logger.info("License plate subscription task cancelled")
# Properly close the async generator
if listen_generator is not None:
try:
await listen_generator.aclose()
except Exception as e:
logger.debug(f"Error closing listen generator: {e}")
except Exception as e: except Exception as e:
logger.error(f"Error in license plate message listener: {e}", exc_info=True) logger.error(f"Error in license plate message listener: {e}", exc_info=True)
# Properly close the async generator on error
if listen_generator is not None:
try:
await listen_generator.aclose()
except Exception as e:
logger.debug(f"Error closing listen generator: {e}")
async def _process_license_plate_result(self, data: Dict[str, Any]): async def _process_license_plate_result(self, data: Dict[str, Any]):
""" """

View file

@ -4,4 +4,5 @@ ultralytics
opencv-python opencv-python
scipy scipy
filterpy filterpy
psycopg2-binary psycopg2-binary
lap>=0.5.12