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