andymccurdy/redis-py — Issue #214: Non-graceful crash when redis connection goes down
Author: jingsong
Created: 2011-11-10 01:37:49+00:00
State: open

I'm using django-redis-cache backend (which utilizes redis-py) with redis. Traceback:

File "/home/dotcloud/current/loyalty/api/models.py", line 48, in expire_apiclient_caches
cache.delete(cache_key)

File "/home/dotcloud/env/lib/python2.6/site-packages/redis_cache/cache.py", line 220, in delete
self._client.delete(self.make_key(key, version=version))

File "/home/dotcloud/env/lib/python2.6/site-packages/redis/client.py", line 276, in delete
return self.execute_command('DEL', *names)

File "/home/dotcloud/env/lib/python2.6/site-packages/redis/client.py", line 238, in execute_command
connection.send_command(*args)

File "/home/dotcloud/env/lib/python2.6/site-packages/redis/connection.py", line 200, in send_command
self.send_packed_command(self.pack_command(*args))

File "/home/dotcloud/env/lib/python2.6/site-packages/redis/connection.py", line 194, in send_packed_command
self.disconnect()

File "/home/dotcloud/env/lib/python2.6/site-packages/redis/connection.py", line 162, in disconnect
self._parser.on_disconnect()

File "/home/dotcloud/env/lib/python2.6/site-packages/redis/connection.py", line 14, in on_disconnect
self._fp.close()

AttributeError: 'NoneType' object has no attribute 'close'

Our hosting provider (dotcloud) ran into some gateway issues and communication with the redis server was being intermittent. This lead to a whole host of requests throwing the AttributeError. Is there a way it can except more gracefully?