async def _call_async_jsonrpc(self, target: str, method: RestMethod, params: Optional[NamedTuple], timeout): # 'aioHttpClient' does not support 'timeout' url = self._create_jsonrpc_url(target, method) async with ClientSession() as session: http_client = aiohttpClient(session, url) request = self._create_jsonrpc_params(method, params) return await http_client.send(request)
async def __send_request(self, *args): client = aiohttpClient(self.session, self.url) # manual retry since the library has hard-coded timeouts while True: try: response = await client.request(*args) break except Exception as e: print("{} !timeout! retrying {}".format(self.url, e)) await asyncio.sleep(1 + random.randint(0, 5)) return response
async def main(loop): async with aiohttp.ClientSession(loop=loop) as session: client = aiohttpClient(session, 'http://127.0.0.1:5000') print('hi') try: response = await client.request('bipartite_graph',{'noddes':{"bipartite_0": [8, 7], "bipartite_1": [3, 4]},"edges": [[3, 8], [4, 7]]}) print(response) except Exception as e: logging.exception("message") print('error message:',str(e))
async def can_perform(self) -> bool: if not self.requirements_met: return False if not self.available: return False if not self.all_required_agents_can_perform(): return False async with aiohttp.ClientSession(loop=self.loop) as session: client = aiohttpClient(session, self.url) response = await client.request('can_perform') return response
async def __send_request(*args): async with aiohttp.ClientSession( loop=asyncio.get_event_loop()) as session: client = aiohttpClient(session, "http://localhost:38391") response = await client.request(*args) return response
async def __send_request(self, *args): client = aiohttpClient(self.session, self.url) response = await client.request(*args) return response
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)
async def perform(self, job: JobDescriptor): async with aiohttp.ClientSession(loop=self.loop) as session: client = aiohttpClient(session, self.url) response = await client.request('perform', (), job) return response
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)