--- a/runtime/ServicePublisher.py Mon Nov 21 15:18:51 2011 +0100
+++ b/runtime/ServicePublisher.py Tue Nov 22 02:06:15 2011 +0100
@@ -22,7 +22,7 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import Zeroconf, socket
+import Zeroconf, socket, threading
class ServicePublisher():
def __init__(self):
@@ -36,9 +36,16 @@
self.port = None
self.server = None
self.service_name = None
+ self.retrytimer = None
def RegisterService(self, name, ip, port):
+ try:
+ self._RegisterService(name, ip, port)
+ except Exception,e:
+ self.retrytimer = threading.Timer(2,self.RegisterService,[name, ip, port])
+ self.retrytimer.start()
+ def _RegisterService(self, name, ip, port):
# name: fully qualified service name
self.service_name = 'Beremiz_%s.%s'%(name,self.service_type)
self.name = name
@@ -47,8 +54,6 @@
if ip is None:
ip = self.gethostaddr()
- print "My IP is :"+ip
-
self.server = Zeroconf.Zeroconf(ip)
# address: IP address as unsigned short, network byte order
@@ -60,8 +65,13 @@
self.ip_32b,
self.port,
properties = self.serviceproperties))
+ print "MDNS brodcasting on :"+ip
+ self.retrytimer=None
def UnRegisterService(self):
+ if self.retrytimer is not None:
+ self.retrytimer.cancel()
+
self.server.unregisterService(
Zeroconf.ServiceInfo(self.service_type,
self.service_name,