test test
test test

Reputation: 87

TypeError: _request() got an unexpected keyword argument 'cookies' (aiohttp)

import random
import asyncio
import json
import aiohttp
import sys
import urllib
from lxml.html.soupparser import parse
from aiohttp import ClientSession
from threading import Thread

def ttest():
    async def fetch(url, session):
        headers = {
            'Host': 'example.com'
        }
        cookies2 = {
            'test': 'test'
        }

        data = '{"test":"test"}'
        async with session.post(url, data=data, headers=headers, cookies=cookies2) as response:
            return await response.read()
    async def bound_fetch(sem, url, session):
        async with sem:
            html = await fetch(url, session)
            print(html)


    async def run(r):
        url = "https://test.com"
        tasks = []
        sem = asyncio.Semaphore(1000)
        async with aiohttp.ClientSession() as session:
            for i in range(r):
                task = asyncio.ensure_future(bound_fetch(sem, url, session))
                tasks.append(task)
            responses = asyncio.gather(*tasks)
            await responses

    number = 1
    loop = asyncio.get_event_loop()
    future = asyncio.ensure_future(run(number))
    loop.run_until_complete(future)

ttest()

This is the error: TypeError: _request() got an unexpected keyword argument 'cookies'

I want use cookies like you see in the code, but i can not, can anyone help me?

Upvotes: 3

Views: 5980

Answers (1)

Andrew Svetlov
Andrew Svetlov

Reputation: 17356

The feature was added on aiohttp GitHub master but not released yet.

Please either install aiohttp from GitHub or wait for a while for aiohttp 3.5 release.

I hope to publish it in a few days.

Upvotes: 1

Related Questions