I'm trying to make command to discord bot ,that takes list from this script and send one random from them.I started program in Python about month ago soo it's actually pretty hard for me.
Problem is that when i run this script appears error : Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x000002EE51BE5B80>
import asyncpraw
import asyncio
from aiohttp import ClientSession
async def get_meme(posses=100):
posts = []
async with ClientSession() as session:
async for subreddit in subreddits:
sub = await reddit.subreddit(subreddit).top(limit=posses, time_filter="week")
for post in sub:
await posts.append(post.url)
await session.close()
return posts
async def main():
task = asyncio.create_task(get_meme())
reddit_memes = await task
print(reddit_memes)