File size: 1,430 Bytes
6c0af85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)