Set the shutdown event via call_soon

Fixes #480

Require aiorpcx 0.5.6, handle ConnectionError appropriately;
this ensures the same bug would give a better error message
This commit is contained in:
Neil Booth 2018-06-04 13:20:36 +09:00
parent 6928b251f8
commit 52658cfc9c
2 changed files with 3 additions and 3 deletions

View File

@ -591,7 +591,7 @@ class Controller(ServerBase):
def rpc_stop(self):
'''Shut down the server cleanly.'''
self.shutdown_event.set()
self.loop.call_soon(self.shutdown_event.set)
return 'stopping'
def rpc_getinfo(self):

View File

@ -16,7 +16,7 @@ import time
from collections import defaultdict, Counter
from functools import partial
from aiorpcx import ClientSession, RPCError, SOCKSProxy
from aiorpcx import ClientSession, RPCError, SOCKSProxy, ConnectionError
from lib.peer import Peer
from lib.util import ConnectionLogger
@ -73,7 +73,7 @@ class PeerSession(ClientSession):
def is_good(self, request, instance):
try:
result = request.result()
except asyncio.CancelledError:
except (asyncio.CancelledError, ConnectionError):
return False
except asyncio.TimeoutError as e:
self.fail(request, str(e))