[PATCH] Zeroconf breaks serve if there is no internet connection

Augie Fackler lists at durin42.com
Wed Oct 29 19:55:09 CDT 2008


The included patch fixes a bug I encountered in the zeroconf extension  
while on a plane. Adding this patch fixes zeroconf in situations when  
no internet connection is available, but allows it to work normally  
when there is one.

# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1225324486 18000
# Node ID 16735a436ca5486ca2734e5ef127cd13c72d039a
# Parent  1493d1e05ca3034a104afca2f49aec2783be3df6
zeroconf: Don't break serve if no internet connection is present.

diff --git a/hgext/zeroconf/__init__.py b/hgext/zeroconf/__init__.py
--- a/hgext/zeroconf/__init__.py
+++ b/hgext/zeroconf/__init__.py
@@ -46,7 +46,11 @@
  def publish(name, desc, path, port):
      global server, localip
      if not server:
-        server = Zeroconf.Zeroconf()
+        try:
+            server = Zeroconf.Zeroconf()
+        except socket.gaierror, e:
+            # if we have no internet connection, this can happen.
+            return
          ip = getip()
          localip = socket.inet_aton(ip)




More information about the Mercurial-devel mailing list