Fix websocket handler bug on Python3.5 with no uvloop

This commit is contained in:
messense 2017-05-15 10:50:13 +08:00
parent 7cc02e84ed
commit 2f84cdd708
No known key found for this signature in database
GPG Key ID: BB41A8A2C716CCA9

View File

@ -206,7 +206,12 @@ class Sanic:
def response(handler):
async def websocket_handler(request, *args, **kwargs):
request.app = self
try:
protocol = request.transport.get_protocol()
except AttributeError:
# On Python3.5 the Transport classes in asyncio do not
# have a get_protocol() method as in uvloop
protocol = request.transport._protocol
ws = await protocol.websocket_handshake(request)
# schedule the application handler