0

I have a very simple implementation on python using redis-py to interface with Redis. As part of the development, I am shutting redis down to simulate a timeout exception. Problem is that I am setting the timeout to a few seconds, but the connection just sits there without timing out.

from redis import StrictRedis
print('Connecting')
redis_instance = StrictRedis(host=settings.REDIS_HOST,
                             port=settings.REDIS_PORT, 
                             db=settings.REDIS_DB,
                             socket_connect_timeout=5,
                             socket_timeout=5,
                                  )
print('Setting key')
redis_instance.set('X','Y')
print('Key SET')

I can see it goes up to Setting key message, but doesnt go beyond that or throw a timeout.

Any idea what I am doing wrong?

Walucas
  • 2,549
  • 1
  • 21
  • 44

1 Answers1

-1

If you shutdown redis before running the code. redis-py raises socket exception ConnectionRefusedError, and redis ConnectionError.

You have not connected the redis yet, how could the connection times out?

Simba
  • 23,537
  • 7
  • 64
  • 76