Skip to content

sock_read timeout's behavior differ from documentation #3808

@GoPavel

Description

@GoPavel

Problem

It's stated in the doc that sock_timeout for aiohttp.web.StreamResponse limits delay between chunks. So I think the following test should be passed:

async def test_read_timeout_between_chunks(aiohttp_client) -> None:
    async def handler(request):
        resp = aiohttp.web.StreamResponse()
        await resp.prepare(request)
        for _ in range(4):
            await asyncio.sleep(0.1)
            await resp.write(b'data\n')
        return resp

    app = web.Application()
    app.add_routes([web.get('/', handler)])

    timeout = aiohttp.ClientTimeout(sock_read=0.2)
    client = await aiohttp_client(app, timeout=timeout)

    res = b''
    async with await client.get('/') as resp:
        res += await resp.read()

    assert res == b'data\n' * 4

However now it's failing with ServerTimeoutError. sock_read is the de facto timeout for all readings from aiohttp.web.StreamResponse.

Your environment

Fedora 30, x86_64 Linux 5.0.17-300.fc30.x86_64
python: 3.7.4
aiohttp: v3.6.0 (b33540c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions