summaryrefslogtreecommitdiff
path: root/redis/connection.py
diff options
context:
space:
mode:
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()