Skip to content

Instantly share code, notes, and snippets.

@teh
Created March 16, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teh/2051574 to your computer and use it in GitHub Desktop.
Save teh/2051574 to your computer and use it in GitHub Desktop.
From d4e033f64f3d2dc93be7ba65875d370678287611 Mon Sep 17 00:00:00 2001
From: Thomas Hunger <tehunger@gmail.com>
Date: Fri, 16 Mar 2012 17:53:53 +0000
Subject: [PATCH] Enable ipv6
---
desir/desir.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/desir/desir.py b/desir/desir.py
index a4f9273..dbe4d0f 100644
--- a/desir/desir.py
+++ b/desir/desir.py
@@ -430,7 +430,9 @@ class Node(object):
def connect(self):
if self._sock:
return
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+ family, _, _, _, _ = socket.getaddrinfo(self.host, self.port)[0]
+ sock = socket.socket(family, socket.SOCK_STREAM)
try:
sock.connect((self.host, self.port))
sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
--
1.7.2.5
@aallamaa
Copy link

I quickly tried it but it doenst work :(

import desir
r=desir.Redis()
r.keys("_")
Traceback (most recent call last):
File "", line 1, in
File "desir/desir.py", line 113, in rediscmd
return methoddct[runcmd](self, name, *args)
File "desir/desir.py", line 401, in runcmd
raise NodeError(e)
desir.desir.NodeError: Error 61 connecting localhost:6379. Connection refused.
r.keys("
")
Traceback (most recent call last):
File "", line 1, in
File "desir/desir.py", line 113, in _rediscmd
return methoddct[runcmd](self, name, *args)
File "desir/desir.py", line 401, in runcmd
raise NodeError(e)
desir.desir.NodeError: Error 61 connecting localhost:6379. Connection refused.

Any idea why ? Never used IPv6 yet :) ( I am on MacOSX Lion by the way)

@teh
Copy link
Author

teh commented Mar 18, 2012

Ah, sorry. If a hosts entry points to more than one IP getaddrinfo will return more than one result and using the first one is essentially random. The following patch prefers ipv4 over ipv6 and should fix the issue.

https://gist.github.com/66b3ccca73abf962cada

@aallamaa
Copy link

Thanks patched/commited/pushed

Have you got a gmail or something ? mine is on my github page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment