Giter Club home page Giter Club logo

Comments (6)

pquentin avatar pquentin commented on September 26, 2024 1

Hello, I can confirm we've hit the same issue in Rally (Elasticsearch benchmarking tool). elastic/rally#1804

from aiohttp.

bdraco avatar bdraco commented on September 26, 2024

This might be a side effect of using the callback done running with a call soon

from aiohttp.

hanse avatar hanse commented on September 26, 2024

I see similar issues in our application. The following code exposes a problem on my machine (Python 3.11):

import asyncio
import random
from typing import Any

import aiohttp


async def main() -> None:
    # Usually works when this is `<= 100`
    num_calls = 120

    client = aiohttp.ClientSession()

    async def call(n: int) -> Any:
        # This service echoes the request body in the response
        # The random timeout is key here, it works when `timeout=None`
        response = await client.put(
            "http://localhost:3000/", timeout=random.random(), json={"n": n}
        )
        body = await response.text()
        return (n, body)

    results = await asyncio.gather(
        *[call(i) for i in range(num_calls)], return_exceptions=True
    )

    for result in results:
        if isinstance(result, Exception):
            print(type(result))
        else:
            print(result)

    await client.close()


asyncio.run(main())

On version 3.8.6 this does what you would expect with the n in the request and in the response matching:

(95, '{"n":95}')
<class 'TimeoutError'>
<class 'TimeoutError'>
<class 'TimeoutError'>
(99, '{"n":99}')
(100, '{"n":100}')
<class 'TimeoutError'>
(102, '{"n":102}')
<class 'TimeoutError'>
(104, '{"n":104}')
(105, '{"n":105}')
<class 'TimeoutError'>
(107, '{"n":107}')
<class 'TimeoutError'>
<class 'TimeoutError'>
(110, '{"n":110}')
<class 'TimeoutError'>
<class 'TimeoutError'>
(113, '{"n":113}')
(114, '{"n":114}')
(115, '{"n":115}')
(116, '{"n":116}')
(117, '{"n":117}')
<class 'TimeoutError'>
<class 'TimeoutError'>

However, on 3.9.0, we see this:
(Seemingly recycling responses after 100 when at least one timed out)

(98, '{"n":98}')
<class 'TimeoutError'>
<class 'TimeoutError'>
<class 'TimeoutError'>
<class 'TimeoutError'>
(103, '{"n":60}')
(104, '{"n":58}')
(105, '{"n":71}')
<class 'TimeoutError'>
<class 'TimeoutError'>
(108, '{"n":77}')
(109, '{"n":100}')
<class 'TimeoutError'>
<class 'TimeoutError'>
<class 'TimeoutError'>
(113, '{"n":26}')
<class 'TimeoutError'>
(115, '{"n":2}')
<class 'TimeoutError'>
(117, '{"n":25}')
(118, '{"n":31}')
<class 'TimeoutError'>

We also saw other unexplainable behaviour that could be caused by this, but I have no evidence nor re-production of that.

from aiohttp.

bdraco avatar bdraco commented on September 26, 2024

Does anyone have a working test case we can merge as an xfail test so we can validate a fix?

from aiohttp.

bdraco avatar bdraco commented on September 26, 2024

bisected this to #7764

from aiohttp.

Dreamsorcerer avatar Dreamsorcerer commented on September 26, 2024

bisected this to #7764

Yeah, I already assumed it would be related to that. Something to do with us previously closing the connection and now we're trying to reuse it.

from aiohttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.