Skip to content

Commit 3eb84c5

Browse files
committed
Jython doesn't define socket.SOL_TCP, but seems to work by using socket.SOL_TCP's constant value, 6. Fix for redis#97
1 parent 368cccd commit 3eb84c5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* 2.2.5 (in development)
2+
* Support Jython, fixing #97.
13
* 2.2.4
24
* WARNING: Potential backwards incompatible change - Changed order of
35
parameters of ZREVRANGEBYSCORE to match those of the actual Redis command.

redis/connection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import threading
44
from redis.exceptions import ConnectionError, ResponseError, InvalidResponse
55

6+
# Jython doesn't define socket.SOL_TCP, but works fine with it's value, 6
7+
try:
8+
SOL_TCP = socket.SOL_TCP
9+
except AttributeError:
10+
SOL_TCP = 6
11+
612
class BaseConnection(object):
713
"Manages TCP communication to and from a Redis server"
814
def __init__(self, host='localhost', port=6379, db=0, password=None,
@@ -33,7 +39,7 @@ def connect(self, redis_instance):
3339
error_message = "Error %s connecting %s:%s. %s." % \
3440
(e.args[0], self.host, self.port, e.args[1])
3541
raise ConnectionError(error_message)
36-
sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
42+
sock.setsockopt(SOL_TCP, socket.TCP_NODELAY, 1)
3743
self._sock = sock
3844
self._fp = sock.makefile('r')
3945
redis_instance._setup_connection()

0 commit comments

Comments
 (0)