Closed no13bus closed 8 years ago
@no13bus Can you show the code that throws that error?
I just ran into this as well.
This code is from: https://github.com/heroku-examples/python-websockets-chat/blob/master/chat.py
@sockets.route('/receive')
def outbox(ws):
"""Sends outgoing chat messages, via `ChatBackend`."""
chats.register(ws)
while ws.socket is not None:
# Context switch while `ChatBackend.start` is running in the background.
gevent.sleep()
The issue does not occur if you downgrade gevent-websocket to version 0.3.6 as discussed here:
https://bitbucket.org/Jeffrey/gevent-websocket/issue/50/errors-with-version-092-and-flask-sockets
However, the last solution provided in that discussion to work with the recent version of gevent-websocket did not work for me.
Hope this helps someone.
It looks like the websocket api changed. An websocket object has no longer a socket
attribute, but a boolean closed
that should indicate if the websocket is open or not.
@jcipriano What happens if you use the solution with while not ws.closed:
?
EDIT: Changed with not ws.closed
to while not ws.closed
Thanks @syntonym, that worked for me.
@syntonym while not ws.closed:
@ondrae You are of course correct. Thanks! BTW: This issue can probably be closed?
while not ws.closed
is indeed proper. I've updated the code in the example chat app repository to feature the new usage. Sorry for the confusion!
my flask version is 0.10. When I type
gunicorn -k flask_sockets.worker chat:app
, there is an error:AttributeError: 'WebSocket' object has no attribute 'socket'
why?