summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2011-03-27 11:50:15 -0700
committerAndy McCurdy <andy@andymccurdy.com>2011-03-27 11:50:15 -0700
commit3eb84c538ab968ae7378ceb2282a31fa0169d34d (patch)
treeb819dfe1597c2ea9207b0a1b3d4a3cb112a7a702 /redis/connection.py
parent368cccd29559ec0915ec5f4739504a55bed2a644 (diff)
downloadredis-py-3eb84c538ab968ae7378ceb2282a31fa0169d34d.tar.gz
Jython doesn't define socket.SOL_TCP, but seems to work by using socket.SOL_TCP's constant value, 6. Fix for #97
Diffstat (limited to 'redis/connection.py')
-rw-r--r--redis/connection.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 9bacb53..5839ebc 100644
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -3,6 +3,12 @@ import socket
import threading
from redis.exceptions import ConnectionError, ResponseError, InvalidResponse
+# Jython doesn't define socket.SOL_TCP, but works fine with it's value, 6
+try:
+ SOL_TCP = socket.SOL_TCP
+except AttributeError:
+ SOL_TCP = 6
+
class BaseConnection(object):
"Manages TCP communication to and from a Redis server"
def __init__(self, host='localhost', port=6379, db=0, password=None,
@@ -33,7 +39,7 @@ class BaseConnection(object):
error_message = "Error %s connecting %s:%s. %s." % \
(e.args[0], self.host, self.port, e.args[1])
raise ConnectionError(error_message)
- sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
+ sock.setsockopt(SOL_TCP, socket.TCP_NODELAY, 1)
self._sock = sock
self._fp = sock.makefile('r')
redis_instance._setup_connection()