При попытке запустить асинхронный код выдает RuntimeError: Event loop is closed

Помогите разобраться. Не представляю в чем проблема

import asyncio
import aiohttp
from ids import friend_list
from aiohttp import ClientSession


async def fetch_json(session, url, params):
    res = await session.request(method='GET', url=url, params=params)
    posts = await res.json()
    if posts.get('error'):
        return (None, 'Cannot reach specified data')
    await parse(posts)


async def parse(posts):
    content = []
    try:
        for post in posts['response']['items']:
            content.append(post['text'])
    except:
        return (None, 'Something wrong with request')
    print(content)
    return content


async def queue(url, params):
    async with ClientSession() as session:
        tasks = []
        for id in friend_list:
            params.update({'owner_id': id})
            tasks.append(fetch_json(session, url, params))

        await asyncio.gather(*tasks)


if __name__ == '__main__':
    url = 'https://api.vk.com/method/wall.get'
    params = {
        'access_token': token,
        'v': '5.130',
        'count': 100,
    }
    asyncio.run(queue(url, params))

Вывод

raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Ответы (0 шт):