You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@asyncio.coroutine
def websocket_handler(request):
ws = web.WebSocketResponse()
ws.start(request)
while True:
msg = yield from ws.receive()
if msg.tp == aiohttp.MsgType.text:
if msg.data == 'close':
yield from ws.close()
else:
ws.send_str(msg.data + '/answer')
elif msg.tp == aiohttp.MsgType.close:
print('websocket connection closed')
elif msg.tp == aiohttp.MsgType.error:
print('ws connection closed with exception %s',
ws.exception())
return ws
print('ws connection closed with exception %s', ws.exception()) -> print('ws connection closed with exception %s' % ws.exception())
Also when print('websocket connection closed') happens after that there is no break -- the loop will still run forever. I am suggesting to replace while True: -> while not ws.closed:
The text was updated successfully, but these errors were encountered:
http://aiohttp.readthedocs.org/en/stable/web.html#websockets
print('ws connection closed with exception %s', ws.exception())
->print('ws connection closed with exception %s' % ws.exception())
Also when
print('websocket connection closed')
happens after that there is nobreak
-- the loop will still run forever. I am suggesting to replacewhile True:
->while not ws.closed:
The text was updated successfully, but these errors were encountered: