Пример #1
0
 async def get_certificate(self):
     sslc = ssl.SSLContext()
     try:
         async with aiorpcx.ClientSession(self.host, self.port, ssl=sslc, proxy=self.proxy) as session:
             return session.transport._ssl_protocol._sslpipe._sslobj.getpeercert(True)
     except ValueError:
         return None
Пример #2
0
async def main():
    async with aiorpcx.ClientSession('localhost', 8888) as session:
        session.send_request('echo', ["Howdy"])
        session.send_request('sum', [2, 4, "b"])

        for request in session.all_requests():
            try:
                await request
            except Exception:
                print(f"ERROR: {request} -> {request.exception()}")
            else:
                print(f"OK: {request} -> {request.result()}")

        batch = session.new_batch()
        batch.add_request('echo', ["Me again"])
        batch.add_request('sum', list(range(50)))
        session.send_batch(batch)
        await batch
        for request in batch:
            try:
                print(f"OK: {request} -> {request.result()}")
            except Exception:
                print(f"ERROR: {request} -> {request.exception()}")