| import sys | |
| import logging | |
| from pathlib import Path | |
| # Add project root to path | |
| project_root = Path(__file__).parent | |
| sys.path.append(str(project_root)) | |
| # Set up logging to see debug information | |
| logging.basicConfig( | |
| level=logging.DEBUG, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| ) | |
| from core.redis_client import redis_client | |
| def main(): | |
| """Debug Redis connection issues""" | |
| print("=== Redis Connection Debug Test ===") | |
| # Test the connection | |
| client = redis_client.get_client() | |
| if client is None: | |
| print("β Redis client is None - connection failed") | |
| return 1 | |
| try: | |
| print("Testing ping...") | |
| result = client.ping() | |
| print(f"β Ping successful: {result}") | |
| print("Testing set/get...") | |
| client.set('debug_test', 'success') | |
| value = client.get('debug_test') | |
| client.delete('debug_test') | |
| if value == 'success': | |
| print("β Set/Get test successful!") | |
| print("π Redis connection is working!") | |
| return 0 | |
| else: | |
| print("β Set/Get test failed") | |
| return 1 | |
| except Exception as e: | |
| print(f"β Redis operation failed: {e}") | |
| import traceback | |
| print(f"Traceback: {traceback.format_exc()}") | |
| return 1 | |
| if __name__ == "__main__": | |
| exit_code = main() | |
| sys.exit(exit_code) | |