Skip to content

Commit b42ae2c

Browse files
author
cshinaver
committed
Remove redundant subscription tracking
Remove redundant _subscriptions set as Redis PubSub client already tracks subscriptions internally through its channels attribute. GitHub-Issue:modelcontextprotocol#342
1 parent 9344142 commit b42ae2c

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/mcp/server/message_queue/redis.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ def __init__(
6363
self._pubsub_thread = None
6464
# Lock for thread safety
6565
self._lock = threading.RLock()
66-
# Tracks current subscriptions
67-
self._subscriptions: set[str] = set()
6866
# Ensures only one polling task runs at a time for message handling
6967
self._limiter = CapacityLimiter(1)
7068
# Active sessions set key
@@ -110,7 +108,6 @@ async def subscribe(self, session_id: UUID, callback: MessageCallback):
110108
with self._lock:
111109
# Subscribe to channel
112110
await anyio.to_thread.run_sync(lambda: self._pubsub.subscribe(channel))
113-
self._subscriptions.add(channel)
114111

115112
logger.debug(f"Subscribing to Redis channel for session {session_id}")
116113

@@ -133,7 +130,6 @@ async def subscribe(self, session_id: UUID, callback: MessageCallback):
133130
await anyio.to_thread.run_sync(
134131
lambda: self._pubsub.unsubscribe(channel)
135132
)
136-
self._subscriptions.discard(channel)
137133

138134
# Delete session key and remove from active sessions
139135
await anyio.to_thread.run_sync(lambda: self._redis.delete(session_key))

0 commit comments

Comments
 (0)