wait for local interface to show up
This commit is contained in:
parent
87be2e8aca
commit
9744653701
1 changed files with 9 additions and 4 deletions
|
@ -83,9 +83,14 @@ class LocalNodesBase(Thread):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def receive(self):
|
def receive(self):
|
||||||
last = time.mktime(time.localtime())
|
last = time.time()
|
||||||
s = self.get_socket()
|
s = None
|
||||||
s.bind(('', self._PORT))
|
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:
|
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, ())
|
||||||
|
|
Loading…
Reference in a new issue