diff --git a/lbry/tests/integration/test_wallet_server_sessions.py b/lbry/tests/integration/test_wallet_server_sessions.py index 451006d48..5234b990c 100644 --- a/lbry/tests/integration/test_wallet_server_sessions.py +++ b/lbry/tests/integration/test_wallet_server_sessions.py @@ -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) diff --git a/torba/tests/client_tests/integration/test_network.py b/torba/tests/client_tests/integration/test_network.py index 5be044cef..fb901196a 100644 --- a/torba/tests/client_tests/integration/test_network.py +++ b/torba/tests/client_tests/integration/test_network.py @@ -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'): diff --git a/torba/torba/client/basenetwork.py b/torba/torba/client/basenetwork.py index 69e3eedb6..92f163f88 100644 --- a/torba/torba/client/basenetwork.py +++ b/torba/torba/client/basenetwork.py @@ -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: diff --git a/torba/torba/rpc/session.py b/torba/torba/rpc/session.py index 049cd22ed..2de40b88c 100644 --- a/torba/torba/rpc/session.py +++ b/torba/torba/rpc/session.py @@ -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()