How to use the jsonrpcclient.clients.aiohttp_client.AiohttpClient function in jsonrpcclient

To help you get started, we’ve selected a few jsonrpcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spesmilo / electrum / electrum / daemon.py View on Github external
async def request_coroutine():
            async with aiohttp.ClientSession(auth=auth, loop=loop) as session:
                server = AiohttpClient(session, server_url)
                f = getattr(server, endpoint)
                response = await f(*args)
                return response.data.result
        try:
github qtumproject / qtum-electrum / electrum / daemon.py View on Github external
async def request_coroutine():
            async with aiohttp.ClientSession(auth=auth) as session:
                server = AiohttpClient(session, server_url, timeout=timeout)
                f = getattr(server, endpoint)
                response = await f(*args)
                return response.data.result
        try:
github qtumproject / qtum-electrum / electrum / lnworker.py View on Github external
    @ignore_exceptions
    @log_exceptions
    async def sync_with_remote_watchtower(self):
        import aiohttp
        from jsonrpcclient.clients.aiohttp_client import AiohttpClient
        class myAiohttpClient(AiohttpClient):
            async def request(self, *args, **kwargs):
                r = await super().request(*args, **kwargs)
                return r.data.result
        while True:
            await asyncio.sleep(5)
            watchtower_url = self.config.get('watchtower_url')
            if not watchtower_url:
                continue
            try:
                async with make_aiohttp_session(proxy=self.network.proxy) as session:
                    watchtower = myAiohttpClient(session, watchtower_url)
                    for chan in self.channels.values():
                        await self.sync_channel_with_watchtower(chan, watchtower)
            except aiohttp.client_exceptions.ClientConnectorError:
                self.logger.info(f'could not contact remote watchtower {watchtower_url}')
github DurianStallSingapore / Zilliqa-Mining-Proxy / zilpool / pyzil / zilliqa_api.py View on Github external
async def init_client(self):
        self.session = ClientSession(loop=self.loop)
        self.api_client = AiohttpClient(
            self.session,
            self.endpoint,
            ssl=context
        )
github bcb / jsonrpcclient / examples / aiohttp / batch.py View on Github external
async def main(loop):

    async with aiohttp.ClientSession(loop=loop) as session:
        client = AiohttpClient(session, "http://localhost:5000")
        requests = [Request("ping"), Notification("ping"), Request("ping")]
        response = await client.send(requests)

    for data in response.data:
        if data.ok:
            print("{}: {}".format(data.id, data.result))
        else:
            logging.error("%d: %s", data.id, data.message)
github bcb / jsonrpcclient / examples / aiohttp / request.py View on Github external
async def main(loop):
    async with aiohttp.ClientSession(loop=loop) as session:
        client = AiohttpClient(session, "http://localhost:5000")
        response = await client.request("ping")
    print(response.data.result)