redis/redis-py · error · RedisError
Pattern ' ' has no handler registered
Error message
Pattern '{pattern}' has no handler registered What it means
KeyspaceNotifications._validate_all_handlers (redis/keyspace_notifications.py:1728, standalone) raises RedisError when any pattern subscription (psubscribe) has a None handler. Same lifecycle as error 432 but for glob-pattern subscriptions. run_in_thread needs a callable per pattern to dispatch incoming messages.
Solutions
- Pass a handler for every pattern subscription before run_in_thread.
- Use get_message()/listen() if you intend to handle messages inline without per-pattern callbacks.
- Audit all subscribe calls so every KeyspacePattern has a non-None handler.
Example fix
// before
notifications.subscribe(KeyspacePattern('user:*'))
notifications.run_in_thread()
// after
notifications.subscribe(KeyspacePattern('user:*'), handler=on_user_event)
notifications.run_in_thread(poll_timeout=0.1) Defensive patterns
Strategy: validation
Validate before calling
def all_patterns_have_handler(ksn) -> bool:
return all(h is not None for _, h in ksn._pubsub.patterns.items()) Prevention
- Pass a handler for every pattern subscription before run_in_thread.
- Use get_message()/listen() if you handle messages inline.
- Ensure every KeyspacePattern subscribe includes a non-None handler.
When it happens
Trigger: notifications.subscribe(KeyspacePattern('user:*'), handler=None) then run_in_thread; subscribing a pattern for listen()/get_message() use and then switching to run_in_thread without a handler.
Common situations: Same as 432 for pattern-based subscriptions; forgetting handler on a KeyspacePattern subscribe.
Related errors
- Channel ' ' has no handler registered
- Pattern: ' ' has no handler registered
- Channel: ' ' has no handler registered
- Failed to subscribe to cluster nodes
- A non health check response was cleaned by execute_command
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/932bde4ea5e8f477.
Report an issue: GitHub.
Appendix: source
Thrown at redis/keyspace_notifications.py:1728
"""
while self.subscribed:
notification = self.get_message(timeout=1.0)
if notification is not None:
yield notification
@property
def subscribed(self) -> bool:
"""Check if there are any active subscriptions and not closed."""
return not self._closed and self._pubsub.subscribed
def _validate_all_handlers(self) -> None:
"""Raise if any subscription in the underlying PubSub lacks a handler."""
for channel, handler in self._pubsub.channels.items():
if handler is None:
raise RedisError(f"Channel '{channel}' has no handler registered")
for pattern, handler in self._pubsub.patterns.items():
if handler is None:
raise RedisError(f"Pattern '{pattern}' has no handler registered")
def close(self):
"""Close the pubsub connection and clean up resources."""
self._closed = True
try:
self._pubsub.close()
except Exception:
pass
# =============================================================================
# Cluster-Aware Keyspace Notification Manager
# =============================================================================
class ClusterKeyspaceNotifications(AbstractKeyspaceNotifications):
"""
Manages keyspace notification subscriptions across all nodes in a Redis Cluster.View on GitHub (pinned to 6a6b581b48)