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

asyncio.TimeoutError does not release the request #612

Closed
Insoleet opened this issue Nov 1, 2015 · 5 comments
Closed

asyncio.TimeoutError does not release the request #612

Insoleet opened this issue Nov 1, 2015 · 5 comments
Labels
Milestone

Comments

@Insoleet
Copy link
Contributor

Insoleet commented Nov 1, 2015

Test showing the bug, based on the API available in test_web_functional :

    def test_simple_timeout(self):

        @asyncio.coroutine
        def handler(request):
            body = yield from request.read()
            self.assertEqual(b'', body)
            yield from asyncio.sleep(2, loop=self.loop)
            return web.Response(body=b'OK')

        @asyncio.coroutine
        def go():
            _, srv, url = yield from self.create_server('GET', '/', handler)
            try:
                resp = yield from asyncio.wait_for(request('GET', url, loop=self.loop), 1, loop=self.loop)
            except TimeoutError:
                pass
            yield from asyncio.sleep(3, loop=self.loop)

Results in the following error :

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7efe1383c048>
Task was destroyed but it is pending!
task: <Task pending coro=<__iter__() running at /home/inso/code/aiohttp/aiohttp/client.py:475> wait_for=<Future pending cb=[BaseSelectorEventLoop._sock_connect_done(8)(), Task._wakeup()]>>
@asvetlov asvetlov added this to the 0.19 milestone Nov 2, 2015
@asvetlov
Copy link
Member

asvetlov commented Nov 2, 2015

The error is not about unreleased request but not closed session.
Should be fixed anyway.

@Insoleet
Copy link
Contributor Author

Insoleet commented Nov 2, 2015

Out of curiosity, what is the difference ? Just so that I better understand how aiohttp works !

Was it fixed some time ago ? I can't find any commit about this bug.

@asvetlov
Copy link
Member

asvetlov commented Nov 2, 2015

It's not fixed yet but we should add a fix.
session can be used for handling multiple requests, keep-alives and cookies: http://aiohttp.readthedocs.org/en/stable/client.html#keep-alive-connection-pooling-and-cookie-sharing
It also support the limit of opened connections via Connector: http://aiohttp.readthedocs.org/en/stable/client.html#limiting-connection-pool-size

Response is just HTTP response for HTTP request.

Calls like request, get etc. create temporary ClientSession internally.

@asvetlov asvetlov added the good first issue Good for newcomers label Nov 8, 2015
@asvetlov asvetlov reopened this Nov 25, 2015
@asvetlov asvetlov modified the milestones: 0.20, 0.19 Nov 25, 2015
@asvetlov
Copy link
Member

Fixed by #707

@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