Skip to content

Commit 97e173f

Browse files
committed
Fix redis connection leak
Signed-off-by: Aidan Butler <aidbutlr@ie.ibm.com>
1 parent bc42180 commit 97e173f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

mcpgateway/plugins/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""Location: ./mcpgateway/plugins/__init__.py
3-
Copyright contributors to the MCP-CONTEXT-FORGE project
3+
Copyright 2026
44
SPDX-License-Identifier: Apache-2.0
5+
Authors: Fred Araujo
56
67
Gateway plugin integration.
78
@@ -498,14 +499,14 @@ async def _plugin_invalidation_listener() -> None:
498499
await asyncio.sleep(10)
499500
continue
500501

501-
pubsub = client.pubsub()
502-
await pubsub.subscribe(_REDIS_INVALIDATION_CHANNEL)
503-
_logger.info("Plugin invalidation listener subscribed to %s", _REDIS_INVALIDATION_CHANNEL)
504-
backoff = 1.0
505-
consecutive_failures = 0
502+
async with client.pubsub() as pubsub:
503+
await pubsub.subscribe(_REDIS_INVALIDATION_CHANNEL)
504+
_logger.info("Plugin invalidation listener subscribed to %s", _REDIS_INVALIDATION_CHANNEL)
505+
backoff = 1.0
506+
consecutive_failures = 0
506507

507-
async for message in pubsub.listen():
508-
await _handle_invalidation_message(message)
508+
async for message in pubsub.listen():
509+
await _handle_invalidation_message(message)
509510

510511
except asyncio.CancelledError:
511512
_logger.info("Plugin invalidation listener cancelled")

0 commit comments

Comments
 (0)