redis_state_listener fix
This commit is contained in:
@@ -127,14 +127,9 @@ async def redis_state_listener():
|
||||
|
||||
logger.info("Redis state listener connected")
|
||||
|
||||
while True:
|
||||
try:
|
||||
message = await asyncio.wait_for(
|
||||
pubsub.get_message(ignore_subscribe_messages=True),
|
||||
timeout=1.0
|
||||
)
|
||||
|
||||
if message and message["type"] == "message":
|
||||
# listen() blocks async and waits for messages - prevents busy loop
|
||||
async for message in pubsub.listen():
|
||||
if message["type"] == "message":
|
||||
data = message["data"]
|
||||
try:
|
||||
state_data = json.loads(data)
|
||||
@@ -146,9 +141,6 @@ async def redis_state_listener():
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to parse state data: {e}")
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
pass # No message, continue
|
||||
|
||||
except asyncio.CancelledError:
|
||||
logger.info("Redis state listener cancelled")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user