MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _execute_redis_command

Method _execute_redis_command

apps/proxy/live_proxy/server.py:122–143  ·  view source on GitHub ↗

Execute Redis command with error handling and reconnection logic

(self, command_func, *args, **kwargs)

Source from the content-addressed store, hash-verified

120 logger.error(f"Failed to connect to Redis after {self.redis_max_retries} attempts")
121
122 def _execute_redis_command(self, command_func, *args, **kwargs):
123 """Execute Redis command with error handling and reconnection logic"""
124 if not self.redis_client:
125 return None
126
127 try:
128 return command_func(*args, **kwargs)
129 except (ConnectionError, TimeoutError) as e:
130 logger.warning(f"Redis connection lost: {e}. Attempting to reconnect...")
131 try:
132 # Try to reconnect
133 self.redis_connection_attempts = 0
134 self._setup_redis_connection()
135 if self.redis_client:
136 # Retry the command once
137 return command_func(*args, **kwargs)
138 except Exception as reconnect_error:
139 logger.error(f"Failed to reconnect to Redis: {reconnect_error}")
140 return None
141 except Exception as e:
142 logger.error(f"Redis command error: {e}")
143 return None
144
145 def _spawn_on_hub(self, fn, *args, **kwargs):
146 """Schedule fn on the gevent hub from any thread without blocking the caller."""

Callers 3

get_channel_ownerMethod · 0.95
try_acquire_ownershipMethod · 0.95
cleanup_taskMethod · 0.95

Calls 1

Tested by

no test coverage detected