Skip to content

Commit

Permalink
Fix bug #355
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Feb 10, 2016
1 parent 8e84045 commit ffa8b86
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/sakia/core/net/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ async def close_ws(self):
if ws:
ws.cancel()
await asyncio.sleep(0)
closed = False
while not closed:
for ws in self._ws_tasks.values():
if ws:
closed = False
break
else:
closed = True
await asyncio.sleep(0)
await asyncio.sleep(0)

@property
def pubkey(self):
Expand Down Expand Up @@ -307,8 +317,11 @@ def refresh(self, manual=False):
Refresh all data of this node
:param bool manual: True if the refresh was manually initiated
"""
self._ws_tasks['block'] = asyncio.ensure_future(self.connect_current_block())
self._ws_tasks['peer'] = asyncio.ensure_future(self.connect_peers())
if not self._ws_tasks['block']:
self._ws_tasks['block'] = asyncio.ensure_future(self.connect_current_block())

if not self._ws_tasks['peer']:
self._ws_tasks['peer'] = asyncio.ensure_future(self.connect_peers())

if self._refresh_counter % 20 == 0 or manual:
self.refresh_informations()
Expand Down

0 comments on commit ffa8b86

Please sign in to comment.