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

Problem when formatting a request encapsulated in a task #590

Closed
Insoleet opened this issue Oct 25, 2015 · 2 comments
Closed

Problem when formatting a request encapsulated in a task #590

Insoleet opened this issue Oct 25, 2015 · 2 comments
Labels

Comments

@Insoleet
Copy link
Contributor

Hello,

The following unit test shows the bug, based on the API available in test_web_functional

    def test_format_task_get(self):

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

        @asyncio.coroutine
        def go():
            _, srv, url = yield from self.create_server('GET', '/', handler)
            client = ClientSession(loop=self.loop)
            task = self.loop.create_task(client.get(url))
            self.assertEqual("{}".format(task)[:18], "<Task pending coro")
        self.loop.run_until_complete(go())
Exception in default exception handler
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/coroutines.py", line 270, in _format_coroutine
    coro_code = coro.gi_code
AttributeError: '_RequestContextManager' object has no attribute 'gi_code'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1057, in call_exception_handler
    self.default_exception_handler(context)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1031, in default_exception_handler
    value = repr(value)
  File "/usr/lib/python3.5/asyncio/futures.py", line 194, in __repr__
    info = self._repr_info()
  File "/usr/lib/python3.5/asyncio/tasks.py", line 102, in _repr_info
    coro = coroutines._format_coroutine(self._coro)
  File "/usr/lib/python3.5/asyncio/coroutines.py", line 272, in _format_coroutine
    coro_code = coro.cr_code
AttributeError: '_RequestContextManager' object has no attribute 'cr_code'

We discovered this bug because quamash formats the task in debug logs ( harvimt/quamash#50 )

@asvetlov
Copy link
Member

Fixed by 0.18.3 release.
Thanks for report

@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