wait for local interface to show up

This commit is contained in:
j 2016-02-24 12:25:17 +05:30
parent 87be2e8aca
commit 9744653701

View file

@ -83,9 +83,14 @@ class LocalNodesBase(Thread):
pass pass
def receive(self): def receive(self):
last = time.mktime(time.localtime()) last = time.time()
s = None
while not s and not state.shutdown:
try:
s = self.get_socket() s = self.get_socket()
s.bind(('', self._PORT)) s.bind(('', self._PORT))
except OSError: # no local interface exists
self.wait(60)
while not state.shutdown: while not state.shutdown:
try: try:
r, _, _ = select.select([s], [], [], 3) r, _, _ = select.select([s], [], [], 3)
@ -105,7 +110,7 @@ class LocalNodesBase(Thread):
self.wait(60) self.wait(60)
finally: finally:
if not state.shutdown: if not state.shutdown:
now = time.mktime(time.localtime()) now = time.time()
if now - last > 60: if now - last > 60:
last = now last = now
_thread.start_new_thread(self.send, ()) _thread.start_new_thread(self.send, ())