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

AttributeError 'transport' with WebSocketResponse.can_prepare #1736

Closed
achimnol opened this issue Mar 21, 2017 · 2 comments
Closed

AttributeError 'transport' with WebSocketResponse.can_prepare #1736

achimnol opened this issue Mar 21, 2017 · 2 comments
Labels

Comments

@achimnol
Copy link
Member

Long story short

Using WebSocketResponse.can_prepare() method in aiohttp 2.0.0 raises AttributeError, regardless of whether to use uvloop or the vanilla asyncio loop.
If I skip a pre-cautious call to can_prepare(), everything works fine.

Expected behaviour

It should continue without AttributeError.

Actual behaviour

With uvloop 0.8:

  File "/Users/joongi/Projects/Lablup/sorna-manager/sorna/gateway/kernel.py", line 502, in stream_pty
    if not ws.can_prepare(request):
  File "/Users/joongi/Projects/Lablup/sorna-manager/venv/lib/python3.6/site-packages/aiohttp/web_ws.py", line 1
40, in can_prepare
    self._protocols)
  File "/Users/joongi/Projects/Lablup/sorna-manager/venv/lib/python3.6/site-packages/aiohttp/http_websocket.py"
, line 570, in do_handshake
    WebSocketWriter(stream, limit=write_buffer_size),
  File "/Users/joongi/Projects/Lablup/sorna-manager/venv/lib/python3.6/site-packages/aiohttp/http_websocket.py"
, line 416, in __init__
    self.writer = stream.transport
AttributeError: 'uvloop.loop.TCPTransport' object has no attribute 'transport'

With vanilla asyncio:

  File "/Users/joongi/Projects/Lablup/sorna-manager/sorna/gateway/kernel.py", line 502, in stream_pty
    if not ws.can_prepare(request):
  File "/Users/joongi/Projects/Lablup/sorna-manager/venv/lib/python3.6/site-packages/aiohttp/web_ws.py", line 1
40, in can_prepare
    self._protocols)
  File "/Users/joongi/Projects/Lablup/sorna-manager/venv/lib/python3.6/site-packages/aiohttp/http_websocket.py"
, line 570, in do_handshake
    WebSocketWriter(stream, limit=write_buffer_size),
  File "/Users/joongi/Projects/Lablup/sorna-manager/venv/lib/python3.6/site-packages/aiohttp/http_websocket.py"
, line 416, in __init__
    self.writer = stream.transport
AttributeError: '_SelectorSocketTransport' object has no attribute 'transport'

Steps to reproduce

Just make a simple WebSocket server and explicitly call can_prepare() like below:

async def my_ws_handler(request):
    ws = web.WebSocketResponse()
    if not ws.can_prepare(request):  # commenting out this if-clause makes it working
        raise web.HTTPUpgradeRequired
    await ws.prepare(request)
    ...

Your environment

Python 3.6.0, aiohttp 2.0.0, uvloop 0.8.0 on macOS Sierra 10.2.1.

@fafhrd91
Copy link
Member

thanks for reporting.

will release 2.0.1 today

@lock
Copy link

lock bot commented Oct 28, 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 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 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