0

Первый раз пишу библеотеку на asyncio для ВК, возникает ошибка которую не знаю как пофиксить C:\Users\newpotsdev\AppData\Local\Programs\Python\Python37\lib\asyncio\events.py:88: RuntimeWarning: coroutine 'ClientResponse.json' was never awaited self._context.run(self._callback, *self._args)

Вот сам код

import aiohttp
import asyncio
import ujson

class Engine(object):
    def __init__(self, vk_group_token, vk_group_id):
        self.vk_group_token = vk_group_token
        self.vk_group_id = vk_group_id
        self.url = "https://api.vk.com/method/"
        self.api_version = '5.101'

    async def method(self, method, args):
        async with aiohttp.ClientSession(json_serialize=ujson.dumps) as session:
            args["access_token"] = self.vk_group_token
            args["v"] = self.api_version
            async with session.post(self.url+method, json=args) as response:
                return response.json()

api = Engine("token", 'id')

async def main():
    args = {
        "offset": 0,
        "count": 20,
        "filter": 'all',
    }
    var = await api.method('messages.getConversations', args)
    print(var)

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Не судите строго, первый раз работаю с asyncio.

1 ответ 1

1

Попробуйте return await response.json() или print(await var).

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.