both exceptions can be raised, depending on when the call happens
This commit is contained in:
parent
8fce374cae
commit
022d60ec2c
4 changed files with 5 additions and 5 deletions
|
@ -26,7 +26,7 @@ class TestSessionBloat(IntegrationTestCase):
|
|||
self.assertEqual(len(self.conductor.spv_node.server.session_mgr.sessions), 1)
|
||||
self.assertFalse(session.is_closing())
|
||||
await asyncio.sleep(1.1)
|
||||
with self.assertRaises(asyncio.TimeoutError):
|
||||
with self.assertRaises((asyncio.TimeoutError, asyncio.CancelledError)):
|
||||
await session.send_request('server.banner', ())
|
||||
self.assertTrue(session.is_closing())
|
||||
self.assertEqual(len(self.conductor.spv_node.server.session_mgr.sessions), 0)
|
||||
|
|
|
@ -35,7 +35,7 @@ class ReconnectTests(IntegrationTestCase):
|
|||
d = self.ledger.network.get_transaction(sendtxid)
|
||||
# what's that smoke on my ethernet cable? oh no!
|
||||
self.ledger.network.client.connection_lost(Exception())
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
with self.assertRaises((asyncio.TimeoutError, asyncio.CancelledError)):
|
||||
await d
|
||||
# rich but offline? no way, no water, let's retry
|
||||
with self.assertRaisesRegex(ConnectionError, 'connection is not available'):
|
||||
|
|
|
@ -169,10 +169,10 @@ class BaseNetwork:
|
|||
return self.rpc('blockchain.block.headers', [height, count])
|
||||
|
||||
def subscribe_headers(self):
|
||||
return self.client.send_request('blockchain.headers.subscribe', [True])
|
||||
return self.rpc('blockchain.headers.subscribe', [True])
|
||||
|
||||
def subscribe_address(self, address):
|
||||
return self.client.send_request('blockchain.address.subscribe', [address])
|
||||
return self.rpc('blockchain.address.subscribe', [address])
|
||||
|
||||
|
||||
class SessionPool:
|
||||
|
|
|
@ -474,7 +474,7 @@ class RPCSession(SessionBase):
|
|||
async def send_request(self, method, args=()):
|
||||
"""Send an RPC request over the network."""
|
||||
if self.is_closing():
|
||||
raise CancelledError()
|
||||
raise asyncio.TimeoutError()
|
||||
message, event = self.connection.send_request(Request(method, args))
|
||||
await self._send_message(message)
|
||||
await event.wait()
|
||||
|
|
Loading…
Reference in a new issue