#async init
1 messages · Page 1 of 1 (latest)
you don't.
OK?
Explain what you're trying to do and show code.
Then just do self.session = aiohttp.ClientSession(...)
and use that session in your async requests methods
You don't create a session in init
Or you can do something more complex like:
https://github.com/onerandomusername/monty-python/blob/main/monty/bot.py#L95-L185
You can pass it from outside
Or that ^
async def main():
async with aiohttp.ClientSession() as session:
bot = ChatBot(..., session=session)
...
await bot.run()
This ensures the session will be closed when the bot quits etc etc
How do you run your bot
Why is that relevant
Your problem is obtaining an async resource during initialization
How's what you posted relevant to the problem