Use an already created sessionΒΆ

If you use aiohttp to make requests on other websites you can pass on the aiohttp.ClientSession object to the PeonyClient on initialisation as the session argument.

import asyncio

import aiohttp
from peony import PeonyClient

async def client_with_session():
    async with aiohttp.ClientSession() as session:
        # The client will use the session to make requests
        client = PeonyClient(**creds, session=session)
        await client.run_tasks()

if __name__ == '__main__':
    asyncio.run(client_with_session())