From 9744653701dadce7c1a50311a55937f23a35667e Mon Sep 17 00:00:00 2001 From: j Date: Wed, 24 Feb 2016 12:25:17 +0530 Subject: [PATCH] wait for local interface to show up --- oml/localnodes.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/oml/localnodes.py b/oml/localnodes.py index 8319e24..9385fc2 100644 --- a/oml/localnodes.py +++ b/oml/localnodes.py @@ -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, ())