summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2011-06-01 14:55:52 -0700
committerAndy McCurdy <andy@andymccurdy.com>2011-06-01 14:55:52 -0700
commit25acfddad36bc85e48052f073f4767009224746f (patch)
treee69519f18716e952be2d8c63b2e724725207f754 /redis/connection.py
parentda1a4e9360c6f5c47ab50f763bffb4f2400b22e4 (diff)
downloadredis-py-25acfddad36bc85e48052f073f4767009224746f.tar.gz
make sure the class instance always has an ._fp attribute in case disconnect gets called before connect
Diffstat (limited to 'redis/connection.py')
-rw-r--r--redis/connection.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 5d6e036..128c359 100644
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -1,18 +1,21 @@
import errno
-import os
import socket
from itertools import chain, imap
from redis.exceptions import ConnectionError, ResponseError, InvalidResponse
class PythonParser(object):
+ def __init__(self):
+ self._fp = None
+
def on_connect(self, connection):
"Called when the socket connects"
self._fp = connection._sock.makefile('r')
def on_disconnect(self):
"Called when the socket disconnects"
- self._fp.close()
- self._fp = None
+ if self._fp is not None:
+ self._fp.close()
+ self._fp = None
def read(self, length=None):
"""