Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
springmaple opened this issue Oct 14, 2016 · 3 comments
Labels

Comments

@springmaple
Copy link
Contributor

springmaple commented Oct 14, 2016

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.

@asvetlov
Copy link
Member

Agree that content reader should be informed.
But just EOF on forced close is not the best solution probably.
I think explicit exception should be thrown.

@asvetlov
Copy link
Member

Fixed by #1323

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants