Last active
          February 4, 2022 16:47 
        
      - 
      
- 
        Save roguh/44efdbcb9dbc7595fd6a5f58fe1bbf0f to your computer and use it in GitHub Desktop. 
    Connect to a redis sentinel
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from redis.sentinel import Sentinel | |
| def connect_to_redis(address: str, port: int, redis_set: str): | |
| sentinel = Sentinel([(address, port)], socket_timeout=0.5) | |
| con = sentinel.master_for( | |
| redis_set, | |
| decode_responses=True, | |
| socket_timeout=0.5, | |
| ) | |
| con.echo("test") | |
| return con | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment