ping on action
This commit is contained in:
parent
4033958341
commit
431dc8e194
1 changed files with 8 additions and 2 deletions
10
oml/nodes.py
10
oml/nodes.py
|
@ -539,9 +539,10 @@ class Nodes(Thread):
|
||||||
def peer_queue(self, peer, action, *args):
|
def peer_queue(self, peer, action, *args):
|
||||||
if peer not in self._nodes:
|
if peer not in self._nodes:
|
||||||
self._add(peer)
|
self._add(peer)
|
||||||
|
elif not self._nodes[peer].is_online():
|
||||||
|
self._nodes[peer].ping()
|
||||||
self._nodes[peer].queue(action, *args)
|
self._nodes[peer].queue(action, *args)
|
||||||
|
|
||||||
|
|
||||||
def is_online(self, id):
|
def is_online(self, id):
|
||||||
return id in self._nodes and self._nodes[id].is_online()
|
return id in self._nodes and self._nodes[id].is_online()
|
||||||
|
|
||||||
|
@ -557,7 +558,12 @@ class Nodes(Thread):
|
||||||
if target == 'all':
|
if target == 'all':
|
||||||
nodes = list(self._nodes.values())
|
nodes = list(self._nodes.values())
|
||||||
elif target == 'peered':
|
elif target == 'peered':
|
||||||
nodes = [n for n in list(self._nodes.values()) if n.user.peered]
|
ids = []
|
||||||
|
with db.session():
|
||||||
|
from user.models import User
|
||||||
|
for u in User.query.filter(User.id != settings.USER_ID).filter_by(peered=True).all():
|
||||||
|
ids.append(u.id)
|
||||||
|
nodes = [n for n in list(self._nodes.values()) if n.user_id in ids]
|
||||||
elif target == 'online':
|
elif target == 'online':
|
||||||
nodes = [n for n in list(self._nodes.values()) if n.online]
|
nodes = [n for n in list(self._nodes.values()) if n.online]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue