network: stop loop on loop thread

This commit is contained in:
Janus 2018-04-13 12:32:29 +02:00
parent 4a4a521f4b
commit 802206bdf3

View File

@ -1114,8 +1114,11 @@ class Network(util.DaemonThread):
networkAndWalletLock.acquire()
# cancel tasks
[f.cancel() for f in self.futures]
self.asyncio_loop.stop()
if self.asyncio_loop.is_running(): time.sleep(0.1)
async def loopstop():
self.asyncio_loop.stop()
asyncio.run_coroutine_threadsafe(loopstop(), self.asyncio_loop)
while self.asyncio_loop.is_running():
time.sleep(0.1)
try:
self.asyncio_loop.close()
except: