Hello people,
I can do ws = environ['wsgi.websocket'] when I use gevent's wsgi server, but
not when I use uwsgi. So how do I get and store a websocket session in uwsgi?
from gevent import monkey; monkey.patch_all()
from gevent.pywsgi import WSGIServer
import uwsgi
class WebSocketApp(object):
def __init__(self):
self.my_dict = {}
self.id_count = 0
def __call__(self, environ, start_response):
uwsgi.websocket_handshake(environ['HTTP_SEC_WEBSOCKET_KEY'],
environ.get('HTTP_ORIGIN', ''))
#works when using gevent's WSGI server but not when using uwsgi
ws = environ['wsgi.websocket']
self.my_dict[self.id_count] = ws
self.id_count += 1
while True:
try:
msg = uwsgi.websocket_recv()
uwsgi.websocket_send(msg)
except IOError, e:
return ""
def send_msg(self, id, msg):
self.my_dict[self.id].websocket_send(msg)
application = WebSocketApp()
Any Help would be much appreciated.
Tim
from gevent import monkey; monkey.patch_all()
from gevent.pywsgi import WSGIServer
import uwsgi
class WebSocketApp(object):
def __init__(self):
self.my_dict = {}
self.id_count = 0
def __call__(self, environ, start_response):
uwsgi.websocket_handshake(environ['HTTP_SEC_WEBSOCKET_KEY'], environ.get('HTTP_ORIGIN', ''))
#works when using gevent's WSGI server but not when using uwsgi
ws = environ['wsgi.websocket']
self.my_dict[self.id_count] = ws
self.id_count += 1
while True:
try:
msg = uwsgi.websocket_recv()
uwsgi.websocket_send(msg)
except IOError:
return ""
def send_msg(self, id, msg):
self.my_dict[self.id].websocket_send(msg)
application = WebSocketApp()
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi