Skip to content

StreamReader.readline() does not break out after ClientResponse object is closed. #1310

@springmaple

Description

@springmaple

Long story short

StreamReader.readline() is stuck for a long time after ClientResponse object is closed and released.

Expected behaviour

I expect ClientResponse.close() to feed eof StreamReader and StreamReader.readline() should break immediately.

Actual behaviour

StreamReader.readline() is stuck for a long time after I called/awaited both ClientResponse.close() and ClientResponse.release().

Steps to reproduce

I am using Twitter streaming API with Python 3.5 asyncio implementation.

Happens when I try to close and release the ClientResponse object while async iterating ClientResponse.content (StreamReader I refers to) in the same loop.

Iter part:

async with ClientSession(loop=loop) as client:
  async with client.request(method, url, data=data,  headers={'Authorization': ...,  'Connection': 'Keep-alive'}, allow_redirects=False) as rsp:
    self.rsp = rsp
    self.reader = rsp.content
    async for rsp_line in rsp.content:
      pass # stuck here for a very long time

Close connection part:

self.rsp.close()
await self.rsp.release()
self.reader.feed_eof()  # I use this to force StreamReader stop immediately.

Your environment

aithttp: version = '1.0.3'
OS: Windows 10 home, 32 bit. version 1607. build 14393.321.
python: 3.5.2, 32 bit.
No proxy server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions