summaryrefslogtreecommitdiff
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
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
-rw-r--r--CHANGES2
-rw-r--r--redis/connection.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 7551cd2..9b8b16a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+* 2.2.5 (in development)
+ * Support Jython, fixing #97.
* 2.2.4
* WARNING: Potential backwards incompatible change - Changed order of
parameters of ZREVRANGEBYSCORE to match those of the actual Redis command.
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()